Part Number Hot Search : 
M1104 AC10EGML AD804206 M1104 E003586 MP351 MRA34P ST70136B
Product Description
Full Text Search
 

To Download MC3S12Q32VFA16 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  hcs12 microcontrollers freescale.com mc9s12q128 reference manual covers mc9s12q family rev 1.09 mc9s12q128 12/2007
to provide the most up-to-date information, the revision of our documents on the world wide web will be the most current. your printed copy may be an earlier revision. to verify you have the latest information available, refer to: http://freescale.com/ a full list of family members and options is included in the appendices. the following revision history table summarizes changes contained in this document. this document contains information for all constituent modules, with the exception of the s12 cpu. for s12 cpu information please refer to the cpu s12 reference manual. date revision level description july, 2005 01.00 new book august, 2005 01.01 corrected typos adjusted lvi assert level added epp package option october, 2005 01.02 corrected typos (pw4 references, pwm registers, 25mhz references) corrected and enhanced pcb layout drawings december, 2005 01.03 added note to pim block diagram ?ure december, 2005 01.04 added pin rerouting note to 80qfp package diagram january, 2006 01.05 updated lvi levels in electrical parameter section fixed incorrect reference to tscr2 may 2006 01.06 added 0m66g part id number corrected missing overbars on pin names added units to mscan timing table dec 2006 01.07 corrected crgflg contents in register summary corrected unintended symbol font may 2007 01.08 added emulation package info. corrected tim and pwm channel count in pim section updated atd section corrected typos and inconsistent register listing format dec 2007 01.09 added new partid
freescale semiconductor mc9s12q128 3 rev 1.09 chapter 1 mc9s12q device overview (mc9s12q128-family) . . . . . . . . 17 chapter 2 port integration module (pim9c32) . . . . . . . . . . . . . . . . . . . . . 73 chapter 3 module mapping control (mmcv4) . . . . . . . . . . . . . . . . . . . . 109 chapter 4 multiplexed external bus interface (mebiv3) . . . . . . . . . . . . 129 chapter 5 interrupt (intv1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 chapter 6 background debug module (bdmv4) . . . . . . . . . . . . . . . . . . 165 chapter 7 debug module (dbgv1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 chapter 8 analog-to-digital converter (atd10b8c) . . . . . . . . . . . . . . . 223 chapter 9 clocks and reset generator (crgv4) . . . . . . . . . . . . . . . . . . 251 chapter 10 scalable controller area network (s12mscanv2) . . . . . . . . 287 chapter 11 oscillator (oscv2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 chapter 12 pulse-width modulator (pwm8b4cv1). . . . . . . . . . . . . . . . . 347 chapter 13 serial communications interface (s12sciv2) . . . . . . . . . . . . 379 chapter 14 serial peripheral interface (spiv3) . . . . . . . . . . . . . . . . . . . . . 409 chapter 15 timer module (tim16b6c) . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 chapter 16 dual output voltage regulator (vreg3v3v2) . . . . . . . . . . . 455 chapter 17 32 kbyte flash module (s12fts32kv1) . . . . . . . . . . . . . . . . . 463 chapter 18 64 kbyte flash module (s12fts64kv4) . . . . . . . . . . . . . . . . . 497 chapter 19 96 kbyte flash module (s12fts96kv1) . . . . . . . . . . . . . . . . . 531 chapter 20 128 kbyte flash module (s12fts128k1v1) . . . . . . . . . . . . . . 565 appendix a electrical characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 appendix b emulation information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 appendix c package information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 appendix d derivative differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 appendix e ordering information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
4 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 5 rev 1.09 chapter 1 mc9s12q device overview (mc9s12q128-family) 1.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 1.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.2 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 1.2.1 device memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 1.2.2 detailed register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 1.2.3 part id assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 1.3 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 1.3.1 device pinouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 1.3.2 signal properties summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 1.3.3 pin initialization for 48- and 52-pin lqfp bond out versions . . . . . . . . . . . . . . . . . . . 49 1.3.4 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 1.3.5 power supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 1.4 system clock description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 1.5 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 1.5.1 chip con?uration summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 1.5.2 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 1.5.3 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 1.6 resets and interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 1.6.1 vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 1.6.2 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.7 device speci? information and module dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.7.1 ppage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.7.2 bdm alternate clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3 1.7.3 extended address range emulation implications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 1.7.4 vregen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.7.5 v dd1 , v dd2 , v ss1 , v ss2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4 1.7.6 clock reset generator and vreg interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.7.7 analog-to-digital converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.7.8 modrr register port t and port p mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.7.9 port ad dependency on pim and atd registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.8 recommended printed circuit board layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 chapter 2 port integration module (pim9c32) block description 2.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 2.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 2.1.2 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 2.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 2.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 2.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6 mc9s12q128 freescale semiconductor rev 1.09 2.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 2.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 2.4.1 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 2.4.2 port descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 2.4.3 port a, b, e and bkgd pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2.4.4 external pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2.4.5 low power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6 2.5 initialization information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2.5.1 reset initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.6.1 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.6.2 recovery from stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.7 application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 chapter 3 module mapping control (mmcv4) block description 3.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 3.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 3.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 10 3.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 3.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 10 3.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 3.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 3.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 3.4.1 bus control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 3.4.2 address decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 3.4.3 memory expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4 chapter 4 multiplexed external bus interface (mebiv3) 4.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 4.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 4.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 31 4.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 4.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 33 4.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 4.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 4.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 4.4.1 detecting access type from external signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 4.4.2 stretched bus cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 51 4.4.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 51 4.4.4 internal visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 4.4.5 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 6
freescale semiconductor mc9s12q128 7 rev 1.09 chapter 5 interrupt (intv1) block description 5.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 5.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 5.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 58 5.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 5.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 59 5.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 5.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 5.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 5.4.1 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2 5.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 5.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 5.6.1 interrupt registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 5.6.2 highest priority i-bit maskable interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 5.6.3 interrupt priority decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3 5.7 exception priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 chapter 6 background debug module (bdmv4) block description 6.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 6.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 6.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 66 6.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 6.2.1 bkgd ?background interface pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 6.2.2 t a ghi ?high byte instruction tagging pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 6.2.3 t a glo ?low byte instruction tagging pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 6.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 68 6.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 6.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 6.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 6.4.1 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 6.4.2 enabling and activating bdm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 6.4.3 bdm hardware commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 6.4.4 standard bdm firmware commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 6.4.5 bdm command structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 6.4.6 bdm serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 79 6.4.7 serial interface hardware handshake protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 6.4.8 hardware handshake abort procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 6.4.9 sync ?request timed reference pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 6.4.10 instruction tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 6.4.11 instruction tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 6.4.12 serial communication time-out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 6.4.13 operation in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 9
8 mc9s12q128 freescale semiconductor rev 1.09 6.4.14 operation in stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 9 chapter 7 debug module (dbgv1) block description 7.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 7.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 7.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 93 7.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 7.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 7.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 96 7.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 7.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 7.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 7.4.1 dbg operating in bkp mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 7.4.2 dbg operating in dbg mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 7.4.3 breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 7.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 7.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 chapter 8 analog-to-digital converter (atd10b8c) block description 8.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 8.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 8.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 23 8.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 8.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.1 an7 / etrig / pad7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.2 an6 / pad6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.3 an5 / pad5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.4 an4 / pad4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.5 an3 / pad3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.6 an2 / pad2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.7 an1 / pad1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.8 an0 / pad0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.9 v rh , v rl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.2.10 v dda , v ssa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 8.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 8.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 8.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 8.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 8.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 8.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 8.5 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
freescale semiconductor mc9s12q128 9 rev 1.09 8.5.1 setting up and starting an a/d conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 8.5.2 aborting an a/d conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 8.6 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 8.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 chapter 9 clocks and reset generator (crgv4) block description 9.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 9.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 9.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 52 9.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 9.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 9.2.1 v ddpll , v sspll ?pll operating voltage, pll ground . . . . . . . . . . . . . . . . . . . . . . 253 9.2.2 xfc ?pll loop filter pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 9.2.3 reset ?reset pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 9.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 54 9.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 9.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 9.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 9.4.1 phase locked loop (pll) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 9.4.2 system clocks generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 9.4.3 clock monitor (cm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 0 9.4.4 clock quality checker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 0 9.4.5 computer operating properly watchdog (cop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 9.4.6 real-time interrupt (rti) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 9.4.7 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 73 9.4.8 low-power operation in run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 9.4.9 low-power operation in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 9.4.10 low-power operation in stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 9.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 9.5.1 clock monitor reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 84 9.5.2 computer operating properly watchdog (cop) reset . . . . . . . . . . . . . . . . . . . . . . . . . 284 9.5.3 power-on reset, low voltage reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 9.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 9.6.1 real-time interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 9.6.2 pll lock interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 9.6.3 self-clock mode interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 chapter 10 freescale? scalable controller area network (s12mscanv2) 10.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 10.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 10.1.2 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 10.1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
10 mc9s12q128 freescale semiconductor rev 1.09 10.1.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 10.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 10.2.1 rxcan ?can receiver input pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 10.2.2 txcan ?can transmitter output pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 10.2.3 can system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 10.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 10.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 10.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 10.3.3 programmers model of message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 10.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 10.4.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 10.4.2 message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 10.4.3 identi?r acceptance filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 7 10.4.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 10.4.5 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 34 10.4.6 reset initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 10.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 10.5 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 10.5.1 mscan initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 41 chapter 11 oscillator (oscv2) block description 11.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 11.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 11.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 11.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 11.2.1 v ddpll and v sspll ?pll operating voltage, pll ground . . . . . . . . . . . . . . . . . . . 344 11.2.2 extal and xtal ?clock/crystal source pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 11.2.3 xclks ?colpitts/pierce oscillator selection signal . . . . . . . . . . . . . . . . . . . . . . . . . 345 11.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 11.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 11.4.1 amplitude limitation control (alc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 11.4.2 clock monitor (cm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 46 11.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 chapter 12 pulse-width modulator (pwm8b4c) block description 12.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 12.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 12.2.1 pwm3 ?pulse width modulator channel 3 pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 12.2.2 pwm2 ?pulse width modulator channel 2 pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
freescale semiconductor mc9s12q128 11 rev 1.09 12.2.3 pwm1 ?pulse width modulator channel 1 pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 12.2.4 pwm0 ?pulse width modulator channel 0 pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 12.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 12.4.1 pwm clock select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 12.4.2 pwm channel timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 12.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 12.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 chapter 13 serial communications interface (s12sciv2) block description 13.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 13.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 13.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 13.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 13.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.2.1 txd-sci transmit pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.2.2 rxd-sci receive pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 13.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 13.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 13.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390 13.4.1 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 13.4.2 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 92 13.4.3 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 13.4.4 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 13.4.5 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 05 13.4.6 loop operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 13.5 initialization information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 13.5.1 reset initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 13.5.2 interrupt operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 13.5.3 recovery from wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 chapter 14 serial peripheral interface (spiv3) block description 14.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 14.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 14.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 14.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 14.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
12 mc9s12q128 freescale semiconductor rev 1.09 14.2.1 mosi ?master out/slave in pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 14.2.2 miso ?master in/slave out pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 14.2.3 ss ?slave select pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 14.2.4 sck ?serial clock pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 14.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 14.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 14.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 14.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 14.4.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 14.4.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 14.4.3 transmission formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 22 14.4.4 spi baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 14.4.5 special features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426 14.4.6 error conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 14.4.7 operation in run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 14.4.8 operation in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 8 14.4.9 operation in stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 8 14.5 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.6.1 modf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.6.2 spif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.6.3 sptef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 chapter 15 timer module (tim16b6cv1) block description 15.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 15.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 15.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 15.1.3 block diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432 15.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 15.2.1 ioc7 ?input capture and output compare channel 7 pin . . . . . . . . . . . . . . . . . . . . 434 15.2.2 ioc6 ?input capture and output compare channel 6 pin . . . . . . . . . . . . . . . . . . . . 434 15.2.3 ioc5 ?input capture and output compare channel 5 pin . . . . . . . . . . . . . . . . . . . . 434 15.2.4 ioc4 ?input capture and output compare channel 4 pin . . . . . . . . . . . . . . . . . . . . 434 15.2.5 ioc3 ?input capture and output compare channel 3 pin . . . . . . . . . . . . . . . . . . . . 434 15.2.6 ioc2 ?input capture and output compare channel 2 pin . . . . . . . . . . . . . . . . . . . . 434 15.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 15.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 15.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 15.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451 15.4.1 prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 15.4.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 15.4.3 output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 15.4.4 pulse accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 15.4.5 event counter mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 53
freescale semiconductor mc9s12q128 13 rev 1.09 15.4.6 gated time accumulation mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 15.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 15.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 15.6.1 channel [7:2] interrupt (c[7:2]f) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 15.6.2 pulse accumulator input interrupt (paovi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 15.6.3 pulse accumulator over?w interrupt (paovf) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 15.6.4 timer over?w interrupt (tof) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 chapter 16 dual output voltage regulator (vreg3v3v2) block description 16.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 16.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 16.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 16.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456 16.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 16.2.1 v ddr ?regulator power input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 16.2.2 v dda , v ssa ?regulator reference supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 16.2.3 v dd , v ss ?regulator output1 (core logic) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 16.2.4 v ddpll , v sspll ?regulator output2 (pll) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 16.2.5 v regen ?optional regulator enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 16.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 16.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 16.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 16.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 16.4.1 reg ?regulator core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.4.2 full-performance mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.4.3 reduced-power mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.4.4 lvd ?low-voltage detect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.4.5 por ?power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.4.6 lvr ?low-voltage reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.4.7 ctrl ?regulator control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 16.5.1 power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 16.5.2 low-voltage reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 16.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 16.6.1 lvi ?low-voltage interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 chapter 17 32 kbyte flash module (s12fts32kv1) 17.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 17.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 17.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 17.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
14 mc9s12q128 freescale semiconductor rev 1.09 17.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 17.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 17.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 17.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 17.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468 17.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480 17.4.1 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480 17.4.2 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494 17.4.3 flash module security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 94 17.4.4 flash reset sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496 17.4.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496 chapter 18 64 kbyte flash module (s12fts64kv4) 18.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 18.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 18.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 18.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498 18.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498 18.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498 18.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 18.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 18.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 18.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514 18.4.1 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514 18.4.2 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528 18.4.3 flash module security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 28 18.4.4 flash reset sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530 18.4.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530 chapter 19 96 kbyte flash module (s12fts96kv1) 19.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531 19.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531 19.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531 19.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 19.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 19.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 19.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 19.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 19.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536 19.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 19.4.1 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 19.4.2 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
freescale semiconductor mc9s12q128 15 rev 1.09 19.4.3 flash module security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 62 19.4.4 flash reset sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 19.4.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 chapter 20 128 kbyte flash module (s12fts128k1v1) 20.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565 20.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565 20.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565 20.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566 20.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566 20.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566 20.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567 20.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567 20.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570 20.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 20.4.1 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 20.4.2 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596 20.4.3 flash module security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 96 20.4.4 flash reset sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598 20.4.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598 appendix a electrical characteristics a.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 a.1.1 parameter classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 99 a.1.2 power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 a.1.3 pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 a.1.4 current injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 a.1.5 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601 a.1.6 esd protection and latch-up immunity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 a.1.7 operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603 a.1.8 power dissipation and thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604 a.1.9 i/o characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606 a.1.10 supply currents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607 a.2 atd characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610 a.2.1 atd operating characteristics in 5v range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610 a.2.2 atd operating characteristics in 3.3v range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 a.2.3 factors influencing accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 a.2.4 atd accuracy (5v range) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612 a.2.5 atd accuracy (3.3v range) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613 a.3 mscan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615 a.4 reset, oscillator and pll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615 a.4.1 startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
16 mc9s12q128 freescale semiconductor rev 1.09 a.4.2 oscillator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616 a.4.3 phase locked loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618 a.5 nvm, flash, and eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621 a.5.1 nvm timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621 a.5.2 nvm reliability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624 a.6 spi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625 a.6.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625 a.6.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627 a.7 voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629 a.7.1 voltage regulator operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629 a.7.2 chip power-up and lvi/lvr graphical explanation . . . . . . . . . . . . . . . . . . . . . . . . . . 629 a.7.3 output loads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630 appendix b emulation information b.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 b.1.1 pk[2:0] / xaddr[16:14]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632 appendix c package information c.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 c.1.1 80-pin qfp package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 34 c.1.2 52-pin lqfp package. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5 c.1.3 48-pin lqfp package. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6 appendix d derivative differences appendix e ordering information
freescale semiconductor mc9s12q128 17 rev 1.09 chapter 1 mc9s12q device overview (mc9s12q128-family) 1.1 introduction the mc9s12q128-family is a 48/52/80 pin flash-based mcu family, which delivers the power and ?xibility of the 16 bit core to a whole new range of cost and space sensitive, general purpose industrial and automotive network applications all mc9s12q128-familymembers feature standard on-chip peripherals including a 16-bit central processing unit (cpu12), up to 128k bytes of flash eeprom (or rom), up to 4k bytes of ram, an asynchronous serial communications interface (sci), a serial peripheral interface (spi), a 6-channel 16-bit timermodule (tim), a 4-channel 8-bit pulse width modulator (pwm), an 8-channel, 10-bit analog-to-digital converter (adc). all mc9s12q128-family devices feature full 16-bit data paths throughout. the inclusion of a pll circuit allows power consumption and performance to be adjusted to suit operational requirements. in addition to the i/o ports available in each module, up to 10 dedicated i/o port bits are available with wake-up capability from stop or wait mode. the mc9s12q128-family devices are available in 48-, 52-, and 80-pin qfp packages, with the 80-pin version pin compatible to the hcs12 a, b,, c and d family derivatives. 1.1.1 features 16-bit hcs12 core: hcs12 cpu upward compatible with m68hc11 instruction set interrupt stacking and programmers model identical to m68hc11 instruction queue enhanced indexed addressing mmc (memory map and interface) int (interrupt control) bdm (background debug mode) dbg12 (enhanced debug12 module, including breakpoints and change-of-?w trace buffer) mebi (multiplexed expansion bus interface) available only in 80-pin package version wake-up interrupt inputs: up to 12 port bits available for wake up interrupt function with digital ?tering
chapter 1 mc9s12q device overview (mc9s12q128-family) 18 mc9s12q128 freescale semiconductor rev 1.09 memory options: 32kbyte rom or flash eeprom (erasable in 512-byte sectors) 64k, 96k, or 128kbyte rom or flash eeprom (erasable in 1024-byte sectors) 1k, 2k, 3k or 4k byte ram analog-to-digital converters: one 8-channel module with 10-bit resolution external conversion trigger capability one 1m bit per second, can 2.0 a, b software compatible module five receive and three transmit buffers flexible identi?r ?ter programmable as 2 x 32 bit, 4 x 16 bit, or 8 x 8 bit four separate interrupt channels for rx, tx, error, and wake-up low-pass ?ter wake-up function loop-back for self test operation timer module (tim): 6-channel timer each channel con?urable as either input capture or output compare simple pwm mode modulo reset of timer counter 16-bit pulse accumulator external event counting gated time accumulation pwm module: programmable period and duty cycle 8-bit 4-channel or 16-bit 2-channel separate control for each pulse width and duty cycle center-aligned or left-aligned outputs programmable clock select logic with a wide range of frequencies fast emergency shutdown input serial interfaces: one asynchronous serial communications interface (sci) one synchronous serial peripheral interface (spi) crg (clock reset generator module) windowed cop watchdog real time interrupt clock monitor pierce or low current colpitts oscillator phase-locked loop clock frequency multiplier limp home mode in absence of external clock low power 0.5mhz to 16mhz crystal oscillator reference clock :operating frequency
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 19 rev 1.09 16mhz equivalent to 8mhz bus speed for single chip 16mhz equivalent to 8mhz bus speed in expanded bus modes option of 32 mhz equivalent to 16mhz bus speed internal 2.5v regulator: supports an input voltage range from 2.97v to 5.5v low power mode capability includes low voltage reset (lvr) circuitry includes low voltage interrupt (lvi) circuitry 48-pin lqfp, 52-pin lqfp, or 80-pin qfp package: up to 58 i/o lines with 5v input and drive capability (80-pin package) up to 2 dedicated 5v input only lines (irq, xirq) 5v 8 a/d converter inputs and 5v i/o development support: single-wire background debug mode (bdm) on-chip hardware breakpoints enhanced dbg12 debug features 1.1.2 modes of operation user modes (expanded modes are only available in the 80-pin package version). normal and emulation operating modes: normal single-chip mode normal expanded wide mode normal expanded narrow mode emulation expanded wide mode emulation expanded narrow mode special operating modes: special single-chip mode with active background debug mode special test mode (freescale use only) special peripheral mode (freescale use only) low power modes: stop mode pseudo stop mode wait mode
chapter 1 mc9s12q device overview (mc9s12q128-family) 20 mc9s12q128 freescale semiconductor rev 1.09 1.1.3 block diagram figure 1-1. mc9s12q128-family block diagram 32k, 64k, 96k, 128k byte flash/rom 1k, 2k, 3k, 4k byte ram mscan vddr vdda vssa vrh vrl atd an2 an6 an0 an7 an1 an3 an4 an5 pad3 pad4 pad5 pad6 pad7 pad0 pad1 pad2 ioc2 ioc6 ioc7 ioc3 ioc4 ioc5 pt3 pt4 pt5 pt6 pt7 pt0 pt1 pt2 rxcan txcan sck miso ps3 ps0 ps1 ps2 ss spi ptad ptt ddrt pts ddrs voltage regulator vdd1 vss1 signals shown in bold are not available on the 52 or 48 pin package ddrad vdda vssa vddx vssx vrh vrl vssr reset extal xtal bkgd r/ w modb/ipipe1 xirq noacc/ xclks system integration module (sim) hcs12 periodic interrupt cop watchdog clock monitor single-wire background pll vsspll xfc vddpll multiplexed address/data bus multiplexed wide bus irq lstrb/ taglo eclk moda/ipipe0 pa4 pa3 pa2 pa1 pa 0 pa7 pa6 pa5 test/vpp addr12 addr11 addr10 addr9 addr8 addr15 addr14 addr13 data12 data11 data10 data9 data8 data15 data14 data13 pb4 pb3 pb2 pb1 pb0 pb7 pb6 pb5 addr4 addr3 addr2 addr1 addr0 addr7 addr6 addr5 data4 data3 data2 data1 data0 data7 data6 data5 pe3 pe4 pe5 pe6 pe7 pe0 pe1 pe2 ddra ddrb pta ptb ddre pte clock and reset generation module debug12 module vdd2 vss2 signals shown in bold italic are available in the 52, but not the 48 pin package cpu pm3 pm4 pm5 pm0 pm1 pm2 ptm ddrm pw2 pw0 pw1 pw3 pp3 pp4 pp5 pp6 pp7 pp0 pp1 pp2 ptp ddrp pj6 pj7 ptj ddrj vdd1,2 vss1,2 vddx vssx internal logic 2.5v vddpll vsspll pll 2.5v i/o driver 5v vdda vssa a/d converter 5v vddr vssr voltage regulator 5v & i/o vrl is bonded internally to vssa for 52 and 48 pin packages mosi keypad interrupt key int sci rxd txd mux pwm module timer module pwm module is only available on the 128k and 96k versions
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 21 rev 1.09 1.2 memory map and registers 1.2.1 device memory map table 1-1 shows the device register map after reset. figure 1-4 through figure 1-7 illustrate the full device memory map. table 1-1. device register map overview address module size 0x0000?x0017 core (ports a, b, e, modes, inits, test) 24 0x0018 reserved 1 0x0019 voltage regulator (vreg) 1 0x001a?x001b device id register 2 0x001c?x001f core (memsiz, irq, hprio) 4 0x0020?x002f core (dbg) 16 0x0030?x0033 core (ppage (1) ) 1. external memory paging is not supported on this device ( section 1.7.1, ?page ). 4 0x0034?x003f clock and reset generator (crg) 12 0x0040?x006f standard timer module (tim) 48 0x0070?x007f reserved 16 0x0080?x009f analog-to-digital converter (atd) 32 0x00a0?x00c7 reserved 40 0x00c8?x00cf serial communications interface (sci) 8 0x00d0?x00d7 reserved 8 0x00d8?x00df serial peripheral interface (spi) 8 0x00e0?x00ff pulse width modulator (pwm) 32 0x0100?x010f flash control register 16 0x0110?x013f reserved 48 0x0140?x017f scalable controller area network (mscan) 64 0x0180?x023f reserved 192 0x0240?x027f port integration module (pim) 64 0x0280?x03ff reserved 384
chapter 1 mc9s12q device overview (mc9s12q128-family) 22 mc9s12q128 freescale semiconductor rev 1.09 figure 1-2. mcxs12q128 user con?urable memory map $0000 $ffff $c000 $8000 $4000 $0400 $ff00 ext normal single chip expanded special single chip vectors vectors $ff00 $ffff bdm (if active) $c000 $ffff 16k fixed flash eeprom/rom $8000 $bfff 16k page window 8 * 16k flash eeprom/rom pages $4000 $7fff 16k fixed flash eeprom/rom $3000 $3fff $0000 $03ff 1k register space mappable to any 2k boundary mappable to any 4k boundary 4k bytes ram $3000 the ?ure shows a useful map, which is not the map out of reset. after reset the map is: $0000 - $03ff: register space $0000 - $0fff: 4k ram (only 3k visible $0400 - $0fff) $0000 $3fff 16k fixed flash eeprom/rom vectors flash erase sector size is 1024 bytes
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 23 rev 1.09 figure 1-3. mcxs12q96 user con?urable memory map $0000 $ffff $c000 $8000 $4000 $0400 $ff00 ext normal single chip expanded special single chip vectors vectors $ff00 $ffff bdm (if active) $c000 $ffff 16k fixed flash eeprom/rom $8000 $bfff 16k page window 6 * 16k flash eeprom/rom pages $4000 $7fff 16k fixed flash eeprom/rom $3400 $3fff $0000 $03ff 1k register space mappable to any 2k boundary mappable to any 4k boundary 3k bytes ram $3400 the ?ure shows a useful map, which is not the map out of reset. after reset the map is: $0000 - $03ff: register space $0400 - $0fff: 3k ram $0000 $3fff 16k fixed flash eeprom/rom vectors flash erase sector size is 1024 bytes
chapter 1 mc9s12q device overview (mc9s12q128-family) 24 mc9s12q128 freescale semiconductor rev 1.09 figure 1-4. mcxs12q64 user con?urable memory map $0000 $ffff $c000 $8000 $4000 $0400 $ff00 normal single chip special single chip vectors $ff00 $ffff bdm (if active) $c000 $ffff 16k fixed flash eeprom/rom $8000 $bfff 16k page window 4 * 16k flash eeprom/rom pages $4000 $7fff 16k fixed flash eeprom/rom $3800 $3fff $0000 $03ff 1k register space mappable to any 2k boundary mappable to any 4k boundary 2k bytes ram $3800 the ?ure shows a useful map, which is not the map out of reset. after reset the map is: $0000 - $03ff: register space $0800 - $0fff: 2k ram $0000 $3fff 16k fixed flash eeprom/rom vectors flash erase sector size is 512 bytes
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 25 rev 1.09 figure 1-5. mcxs12q32 user con?urable memory map $0000 $ffff $c000 $8000 $4000 $0400 $ff00 normal single chip special single chip vectors $ff00 $ffff bdm (if active) $c000 $ffff 16k fixed flash eeprom/rom $8000 $bfff 16k page window 2 * 16k flash eeprom/rom pages $3c00 $3fff $0000 $03ff 1k register space mappable to any 2k boundary mappable to any 2k boundary 1k bytes ram $3c00 the ?ure shows a useful map, which is not the map out of reset. after reset the map is: $0000 - $03ff: register space $0c00 - $0fff: 1k ram vectors flash erase sector size is 512 bytes
chapter 1 mc9s12q device overview (mc9s12q128-family) 26 mc9s12q128 freescale semiconductor rev 1.09 1.2.2 detailed register map the detailed register map of the mc9s12q128-family is listed in address order below. 0x0000?x000f mebi map 1 of 3 (hcs12 multiplexed external bus interface) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0000 porta read: bit 7 6 5 4 3 2 1 bit 0 write: 0x0001 portb read: bit 7 6 5 4 3 2 1 bit 0 write: 0x0002 ddra read: bit 7 6 5 4 3 2 1 bit 0 write: 0x0003 ddrb read: bit 7 6 5 4 3 2 1 bit 0 write: 0x0004 reserved read: 0 0 0 0 0 0 0 0 write: 0x0005 reserved read: 0 0 0 0 0 0 0 0 write: 0x0006 reserved read: 0 0 0 0 0 0 0 0 write: 0x0007 reserved read: 0 0 0 0 0 0 0 0 write: 0x0008 porte read: bit 7 6 5 4 3 2 bit 1 bit 0 write: 0x0009 ddre read: bit 7 6 5 4 3 bit 2 00 write: 0x000a pear read: noacce 0 pipoe neclk lstre rdwe 00 write: 0x000b mode read: modc modb moda 0 ivis 0 emk eme write: 0x000c pucr read: pupke 00 pupee 00 pupbe pupae write: 0x000d rdriv read: rdpk 00 rdpe 00 rdpb rdpa write: 0x000e ebictl read: 0 0 0 0 0 0 0 estr write: 0x000f reserved read: 0 0 0 0 0 0 0 0 write:
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 27 rev 1.09 0x0010?x0014 mmc map 1 of 4 (hcs12 module mapping control) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0010 initrm read: ram15 ram14 ram13 ram12 ram11 00 ramhal write: 0x0011 initrg read: 0 reg14 reg13 reg12 reg11 000 write: 0x0012 initee read: ee15 ee14 ee13 ee12 ee11 00 eeon write: 0x0013 misc read: 0 0 0 0 exstr1 exstr0 romhm romon write: 0x0014 reserved read: 0 0 0 0 0 0 0 0 write: 0x0015?x0016 int map 1 of 2 (hcs12 interrupt) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0015 itcr read: 0 0 0 wrint adr3 adr2 adr1 adr0 write: 0x0016 itest read: inte intc inta int8 int6 int4 int2 int0 write: 0x0017?x0017 mmc map 2 of 4 (hcs12 module mapping control) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0017 reserved read: 0 0 0 0 0 0 0 0 write: 0x0018?x0018 miscellaneous peripherals (device user guide) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0018 reserved read: 0 0 0 0 0 0 0 0 write: 0x0019?x0019 vreg3v3 (voltage regulator) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0019 vregctrl read: 0 0 0 0 0 lvds lvie lvif write:
chapter 1 mc9s12q device overview (mc9s12q128-family) 28 mc9s12q128 freescale semiconductor rev 1.09 0x001a?x001b miscellaneous peripherals (device user guide) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x001a partidh read: id15 id14 id13 id12 id11 id10 id9 id8 write: 0x001b partidl read: id7 id6 id5 id4 id3 id2 id1 id0 write: 0x001c?x001d mmc map 3 of 4 (hcs12 module mapping control, device user guide) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x001c memsiz0 read: reg_sw0 0 eep_sw1 eep_sw0 0 ram_sw2 ram_sw1 ram_sw0 write: 0x001d memsiz1 read: rom_sw1 rom_sw0 0 0 0 0 pag_sw1 pag_sw0 write: 0x001e?x001e mebi map 2 of 3 (hcs12 multiplexed external bus interface) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x001e intcr read: irqe irqen 000000 write: 0x001f?x001f int map 2 of 2 (hcs12 interrupt) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x001f hprio read: psel7 psel6 psel5 psel4 psel3 psel2 psel1 0 write: 0x0020?x002f dbg (including bkp) map 1 of 1 (hcs12 debug) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0020 dbgc1 read: dbgen arm trgsel begin dbgbrk 0 capmod write: 0x0021 dbgsc read: af bf cf 0 trg write: 0x0022 dbgtbh read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: 0x0023 dbgtbl read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: 0x0024 dbgcnt read: tbf 0 cnt write: 0x0025 dbgccx read: pagsel extcmp write:
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 29 rev 1.09 0x0026 dbgcch read: bit 15 14 13 12 11 10 9 bit 8 write: 0x0027 dbgccl read: bit 7 6 5 4 3 2 1 bit 0 write: 0x0028 dbgc2 read: bkaben full bdm tagab bkcen tagc rwcen rwc bkpct0 write: 0x0029 dbgc3 read: bkambh bkambl bkbmbh bkbmbl rwaen rwa rwben rwb bkpct1 write: 0x002a dbgcax read: pagsel extcmp bkp0x write: 0x002b dbgcah read: bit 15 14 13 12 11 10 9 bit 8 bkp0h write: 0x002c dbgcal read: bit 7 6 5 4 3 2 1 bit 0 bkp0l write: 0x002d dbgcbx read: pagsel extcmp bkp1x write: 0x002e dbgcbh read: bit 15 14 13 12 11 10 9 bit 8 bkp1h write: 0x002f dbgcbl read: bit 7 6 5 4 3 2 1 bit 0 bkp1l write: 0x0030?x0031 mmc map 4 of 4 (hcs12 module mapping control) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0030 ppage read: 0 0 pix5 pix4 pix3 pix2 pix1 pix0 write: 0x0031 reserved read: 0 0 0 0 0 0 0 0 write: 0x0032?x0033 mebi map 3 of 3 (hcs12 multiplexed external bus interface) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0032 reserved read: 0 0 0 0 0 0 0 0 write: $0033 reserved read: 0 0 0 0 0 0 0 0 write: 0x0020?x002f dbg (including bkp) map 1 of 1 (hcs12 debug) (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) 30 mc9s12q128 freescale semiconductor rev 1.09 0x0034?x003f crg (clock and reset generator) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0034 synr read: 0 0 syn5 syn4 syn3 syn2 syn1 syn0 write: 0x0035 refdv read: 0 0 0 0 refdv3 refdv2 refdv1 refdv0 write: 0x0036 ctflg test only read: tout7 tout6 tout5 tout4 tout3 tout2 tout1 tout0 write: 0x0037 crgflg read: rtif porf lvrf lockif lock track scmif scm write: 0x0038 crgint read: rtie 00 lockie 00 scmie 0 write: 0x0039 clksel read: pllsel pstp syswai roawai pllwai cwai rtiwai copwai write: 0x003a pllctl read: cme pllon auto acq 0 pre pce scme write: 0x003b rtictl read: 0 rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 write: 0x003c copctl read: wcop rsbck 000 cr2 cr1 cr0 write: 0x003d forbyp test only read: rtibyp copbyp 0 pllbyp 00 fcm 0 write: 0x003e ctctl test only read: tctl7 tctl6 tctl5 tctl4 tclt3 tctl2 tctl1 tctl0 write: 0x003f armcop read: 0 0 0 0 0 0 0 0 write: bit 7 6 5 4 3 2 1 bit 0 0x0040-0x006f tim address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0040 tios read: ios7 ios6 ios5 ios4 ios3 ios2 write: 0x0041 cforc read: 00000000 write: foc7 foc6 foc5 foc4 foc3 foc2 0x0042 oc7m read: oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 write: 0x0043 oc7d read: oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 write: 0x0044 tcnt (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x0045 tcnt (lo) read: bit 7 654321 bit 0 write: 0x0046 tscr1 read: ten tswai tsfrz tffca 0000 write:
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 31 rev 1.09 0x0047 ttov read: tov7 tov6 tov5 tov4 tov3 tov2 write: 0x0048 tctl1 read: om7 ol7 om6 ol6 om5 ol5 om4 ol4 write: 0x0049 tctl2 read: om3 ol3 om2 ol2 write: 0x004a tctl3 read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: 0x004b tctl4 read: edg3b edg3a edg2b edg2a write: 0x004c tie read: c7i c6i c5i c4i c3i c2i c1i c0i write: 0x004d tscr2 read: toi 000 tcre pr2 pr1 pr0 write: 0x004e tflg1 read: c7f c6f c5f c4f c3f c2f write: 0x004f tflg2 read: tof 0000000 write: 0x0050 reserved read: write: 0x0051 reserved read: write: 0x0052 reserved read: write: 0x0053 reserved read: write: 0x0054 tc2 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x0055 tc2 (lo) read: bit 7 654321 bit 0 write: 0x0056 tc3 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x0057 tc3 (lo) read: bit 7 654321 bit 0 write: 0x0058 tc4 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x0059 tc4 (lo) read: bit 7 654321 bit 0 write: 0x005a tc5 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x005b tc5 (lo) read: bit 7 654321 bit 0 write: 0x0040-0x006f tim address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) 32 mc9s12q128 freescale semiconductor rev 1.09 0x005c tc6 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x005d tc6 (lo) read: bit 7 654321 bit 0 write: 0x005e tc7 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x005f tc7 (lo) read: bit 7 654321 bit 0 write: 0x0060 pactl read: 0 paen pamod pedge clk1 clk0 paovi pai write: 0x0061 paflg read: 000000 paovf paif write: 0x0062 pacnt (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: 0x0063 pacnt (lo) read: bit 7 654321 bit 0 write: 0x0064 reserved read: 00000000 write: 0x0065 reserved read: 00000000 write: 0x0066 reserved read: 00000000 write: 0x0067 reserved read: 00000000 write: 0x0068 reserved read: 00000000 write: 0x0069 reserved read: 00000000 write: 0x006a reserved read: 00000000 write: 0x006b reserved read: 00000000 write: 0x006c reserved read: 00000000 write: 0x006d reserved read: 00000000 write: 0x006e reserved read: 00000000 write: 0x006f reserved read: 00000000 write: 0x0040-0x006f tim address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 33 rev 1.09 0x0070?x007f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0070 0x007f reserved read: 0 0 0 0 0 0 0 0 write: 0x0080?x009f atd (analog-to-digital converter 10 bit 8 channel) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0080 atdctl0 read: 0 0 0 0 0 0 0 0 write: 0x0081 atdctl1 read: 0 0 0 0 0 0 0 0 write: 0x0082 atdctl2 read: adpu affc awai etrigle etrigp etrig ascie ascif write: 0x0083 atdctl3 read: 0 s8c s4c s2c s1c fifo frz1 frz0 write: 0x0084 atdctl4 read: sres8 smp1 smp0 prs4 prs3 prs2 prs1 prs0 write: 0x0085 atdctl5 read: djm dsgn scan mult 0 cc cb ca write: 0x0086 atdstat0 read: scf 0 etorf fifor 0 cc2 cc1 cc0 write: 0x0087 reserved read: 0 0 0 0 0 0 0 0 write: 0x0088 atdtest0 read: 0 0 0 0 0 0 0 0 write: 0x0089 atdtest1 read: 0 0 0 0 0 0 0 sc write: 0x008a reserved read: 0 0 0 0 0 0 0 0 write: 0x008b atdstat1 read: ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 write: 0x008c reserved read: 0 0 0 0 0 0 0 0 write: 0x008d atddien read: bit 7 6 5 4 3 2 1 bit 0 write: 0x008e reserved read: 0 0 0 0 0 0 0 0 write: 0x008f portad read: bit7 6 5 4 3 2 1 bit 0 write: 0x0090 atddr0h read: bit15 14 13 12 11 10 9 bit8 write: 0x0091 atddr0l read: bit7 bit6 0 0 0 0 0 0 write: 0x0092 atddr1h read: bit15 14 13 12 11 10 9 bit8 write:
chapter 1 mc9s12q device overview (mc9s12q128-family) 34 mc9s12q128 freescale semiconductor rev 1.09 0x0093 atddr1l read: bit7 bit6 0 0 0 0 0 0 write: 0x0094 atddr2h read: bit15 14 13 12 11 10 9 bit8 write: 0x0095 atddr2l read: bit7 bit6 0 0 0 0 0 0 write: 0x0096 atddr3h read: bit15 14 13 12 11 10 9 bit8 write: 0x0097 atddr3l read: bit7 bit6 0 0 0 0 0 0 write: 0x0098 atddr4h read: bit15 14 13 12 11 10 9 bit8 write: 0x0099 atddr4l read: bit7 bit6 0 0 0 0 0 0 write: 0x009a atddr5h read: bit15 14 13 12 11 10 9 bit8 write: 0x009b atddr5l read: bit7 bit6 0 0 0 0 0 0 write: 0x009c atddr6h read: bit15 14 13 12 11 10 9 bit8 write: 0x009d atddr6l read: bit7 bit6 0 0 0 0 0 0 write: 0x009e atddr7h read: bit15 14 13 12 11 10 9 bit8 write: 0x009f atddr7l read: bit7 bit6 0 0 0 0 0 0 write: 0x00a0?x00c7 reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00a0 0x00c7 reserved read: 0 0 0 0 0 0 0 0 write: 0x00c8?x00cf sci (asynchronous serial interface) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00c8 scibdh read: 0 0 0 sbr12 sbr11 sbr10 sbr9 sbr8 write: 0x00c9 scibdl read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: 0x00ca scicr1 read: loops sciswai rsrc m wake ilt pe pt write: 0x00cb scicr2 read: tie tcie rie ilie te re rwu sbk write: 0x0080?x009f atd (analog-to-digital converter 10 bit 8 channel) (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 35 rev 1.09 0x00cc scisr1 read: tdre tc rdrf idle or nf fe pf write: 0x00cd scisr2 read: 0 0 0 0 0 brk13 txdir raf write: 0x00ce scidrh read: r8 t8 000000 write: 0x00cf scidrl read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 0x00d0?x00d7 reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00d0 0x00d7 reserved read: 0 0 0 0 0 0 0 0 write: 0x00d8?x00df spi (serial peripheral interface) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00d8 spicr1 read: spie spe sptie mstr cpol cpha ssoe lsbfe write: 0x00d9 spicr2 read: 0 0 0 modfen bidiroe 0 spiswai spc0 write: 0x00da spibr read: 0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 write: 0x00db spisr read: spif 0 sptef modf 0 0 0 0 write: 0x00dc reserved read: 0 0 0 0 0 0 0 0 write: 0x00dd spidr read: bit7 6 5 4 3 2 1 bit0 write: 0x00de reserved read: 0 0 0 0 0 0 0 0 write: 0x00df reserved read: 0 0 0 0 0 0 0 0 write: 0x00c8?x00cf sci (asynchronous serial interface) (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) 36 mc9s12q128 freescale semiconductor rev 1.09 0x00e0-0x00ff pwm address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00e0 pwme read: 0 0 pwme3 pwme2 pwme1 pwme0 write: 0x00e1 pwmpol read: 0 0 ppol3 ppol2 ppol1 ppol0 write: 0x00e2 pwmclk read: 0 0 pclk3 pclk2 pclk1 pclk0 write: 0x00e3 pwmprclk read: 0 pckb2 pckb1 pckb0 0 pcka2 pcka1 pcka0 write: 0x00e4 pwmcae read: 0 0 cae3 cae2 cae1 cae0 write: 0x00e5 pwmctl read: 0 con23 con01 pswai pfrz 0 0 write: 0x00e6 pwmtst test only read: 00000000 write: 0x00e7 pwmprsc read: 00000000 write: 0x00e8 pwmscla read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00e9 pwmsclb read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00ea pwmscnta read: 00000000 write: 0x00eb pwmscntb read: 00000000 write: 0x00ec pwmcnt0 read: bit 7 6 5 4 3 2 1 bit 0 write: 00000000 0x00ed pwmcnt1 read: bit 7 6 5 4 3 2 1 bit 0 write: 00000000 0x00ee pwmcnt2 read: bit 7 6 5 4 3 2 1 bit 0 write: 00000000 0x00ef pwmcnt3 read: bit 7 6 5 4 3 2 1 bit 0 write: 00000000 0x00e0 reserved read: write: 0x00e1 reserved read: write: 0x00e2 pwmper0 read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00e3 pwmper1 read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00e4 pwmper2 read: bit 7 6 5 4 3 2 1 bit 0 write:
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 37 rev 1.09 0x00e5 pwmper3 read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00e6 reserved read: write: 0x00e7 reserved read: write: 0x00e8 pwmdty0 read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00e9 pwmdty1 read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00ea pwmdty2 read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00eb pwmdty3 read: bit 7 6 5 4 3 2 1 bit 0 write: 0x00ec reserved read: write: 0x00ed reserved read: write: 0x00ee reserved read: pwmif pwmie 0 pwmlvl 0 pwm5in pwm5inl pwm5ena write: pwmrstr t 0x00ef reserved read: 00000000 write: 0x0100?x010f flash control register address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0100 fclkdiv read: fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 write: 0x0101 fsec read: keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 write: 0x0102 ftstmod read: 0 0 0 wrall 000 0 write: 0x0103 fcnfg read: cbeie ccie keyacc 00000 write: 0x0104 fprot read: fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 write: 0x0105 fstat read: cbeif ccif pviol accerr 0 blank 00 write: 0x0106 fcmd read: 0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 write: 0x0107 reserved for factory test read: 0 0 0 0 0 0 0 0 write: 0x00e0-0x00ff pwm address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) 38 mc9s12q128 freescale semiconductor rev 1.09 0x0108 reserved for factory test read: 0 0 0 0 0 0 0 0 write: 0x0109 reserved for factory test read: 0 0 0 0 0 0 0 0 write: 0x010a reserved for factory test read: 0 0 0 0 0 0 0 0 write: 0x010b reserved for factory test read: 0 0 0 0 0 0 0 0 write: 0x010c reserved read: 0 0 0 0 0 0 0 0 write: 0x010d reserved read: 0 0 0 0 0 0 0 0 write: 0x010e reserved read: 0 0 0 0 0 0 0 0 write: 0x010f reserved read: 0 0 0 0 0 0 0 0 write: 0x0110?x013f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0110 0x003f reserved read: 0 0 0 0 0 0 0 0 write: 0x0140?x017f can (scalable controller area network ?mscan) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0140 canctl0 read: rxfrm rxact cswai synch time wupe slprq initrq write: 0x0141 canctl1 read: cane clksrc loopb listen 0 wupm slpak initak write: 0x0142 canbtr0 read: sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 write: 0x0143 canbtr1 read: samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 write: 0x0144 canrflg read: wupif cscif rstat1 rstat0 tstat1 tstat0 ovrif rxf write: 0x0145 canrier read: wupie cscie rstate1 rstate0 tstate1 tstate0 ovrie rxfie write: 0x0146 cantflg read: 0 0 0 0 0 txe2 txe1 txe0 write: 0x0147 cantier read: 0 0 0 0 0 txeie2 txeie1 txeie0 write: 0x0100?x010f flash control register (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 39 rev 1.09 0x0148 cantarq read: 0 0 0 0 0 abtrq2 abtrq1 abtrq0 write: 0x0149 cantaak read: 0 0 0 0 0 abtak2 abtak1 abtak0 write: 0x014a cantbsel read: 0 0 0 0 0 tx2 tx1 tx0 write: 0x014b canidac read: 0 0 idam1 idam0 0 idhit2 idhit1 idhit0 write: 0x014c reserved read: 0 0 0 0 0 0 0 0 write: 0x014d reserved read: 0 0 0 0 0 0 0 0 write: 0x014e canrxerr read: rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 write: 0x014f cantxerr read: txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 write: 0x0150 0x0153 canidar0 - canidar3 read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: 0x0154 0x0157 canidmr0 - canidmr3 read: am7 am6 am5 am4 am3 am2 am1 am0 write: 0x0158 0x015b canidar4 - canidar7 read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: 0x015c 0x015f canidmr4 - canidmr7 read: am7 am6 am5 am4 am3 am2 am1 am0 write: 0x0160 0x016f canrxfg read: foreground receive buffer see table 1-2 write: 0x0170 0x017f cantxfg read: foreground transmit buffer see table 1-2 write: table 1-2. detailed mscan foreground receive and transmit buffer layout address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0xxxx0 extended id read: id28 id27 id26 id25 id24 id23 id22 id21 standard id read: id10 id9 id8 id7 id6 id5 id4 id3 canxridr0 write: 0xxxx1 extended id read: id20 id19 id18 srr=1 ide=1 id17 id16 id15 standard id read: id2 id1 id0 rtr ide=0 canxridr1 write: 0xxxx2 extended id read: id14 id13 id12 id11 id10 id9 id8 id7 standard id read: canxridr2 write: 0xxxx3 extended id read: id6 id5 id4 id3 id2 id1 id0 rtr standard id read: canxridr3 write: 0x0140?x017f can (scalable controller area network ?mscan) (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) 40 mc9s12q128 freescale semiconductor rev 1.09 0xxxx4 0xxxxb canxrdsr0 canxrdsr7 read: db7 db6 db5 db4 db3 db2 db1 db0 write: 0xxxxc canrxdlr read: dlc3 dlc2 dlc1 dlc0 write: 0xxxxd reserved read: write: 0xxxxe canxrtsrh read: tsr15 tsr14 tsr13 tsr12 tsr11 tsr10 tsr9 tsr8 write: 0xxxxf canxrtsrl read: tsr7 tsr6 tsr5 tsr4 tsr3 tsr2 tsr1 tsr0 write: 0xxx10 extended id read: id28 id27 id26 id25 id24 id23 id22 id21 canxtidr0 write: standard id read: id10 id9 id8 id7 id6 id5 id4 id3 write: 0xxx11 extended id read: id20 id19 id18 srr=1 ide=1 id17 id16 id15 canxtidr1 write: standard id read: id2 id1 id0 rtr ide=0 write: 0xxx12 extended id read: id14 id13 id12 id11 id10 id9 id8 id7 canxtidr2 write: standard id read: write: 0xxx13 extended id read: id6 id5 id4 id3 id2 id1 id0 rtr canxtidr3 write: standard id read: write: 0xxx14 0xxx1b canxtdsr0 canxtdsr7 read: db7 db6 db5 db4 db3 db2 db1 db0 write: 0xxx1c canxtdlr read: dlc3 dlc2 dlc1 dlc0 write: 0xxx1d conxttbpr read: prio7 prio6 prio5 prio4 prio3 prio2 prio1 prio0 write: 0xxx1e canxttsrh read: tsr15 tsr14 tsr13 tsr12 tsr11 tsr10 tsr9 tsr8 write: 0xxx1f canxttsrl read: tsr7 tsr6 tsr5 tsr4 tsr3 tsr2 tsr1 tsr0 write: 0x0180?x023f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0180 0x023f reserved read: 0 0 0 0 0 0 0 0 write: table 1-2. detailed mscan foreground receive and transmit buffer layout (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 41 rev 1.09 0x0240?x027f pim (port interface module) (sheet 1 of 3) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0240 ptt read: ptt7 ptt6 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 write: 0x0241 ptit read: ptit7 ptit6 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 write: 0x0242 ddrt read: ddrt7 ddrt7 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 write: 0x0243 rdrt read: rdrt7 rdrt6 rdrt5 rdrt4 rdrt3 rdrt2 rdrt1 rdrt0 write: 0x0244 pert read: pert7 pert6 pert5 pert4 pert3 pert2 pert1 pert0 write: 0x0245 ppst read: ppst7 ppst6 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 write: 0x0246 reserved read: 0 0 0 0 0 0 0 0 write: 0x0247 modrr read: 0 0 0 modrr4 modrr3 modrr2 modrr1 modrr0 write: 0x0248 pts read: 0 0 0 0 pts3 pts2 pts1 pts0 write: 0x0249 ptis read: 0 0 0 0 ptis3 ptis2 ptis1 ptis0 write: 0x024a ddrs read: 0 0 0 0 ddrs3 ddrs2 ddrs1 ddrs0 write: 0x024b rdrs read: 0 0 0 0 rdrs3 rdrs2 rdrs1 rdrs0 write: 0x024c pers read: 0 0 0 0 pers3 pers2 pers1 pers0 write: 0x024d ppss read: 0 0 0 0 ppss3 ppss2 ppss1 ppss0 write: 0x024e woms read: 0 0 0 0 woms3 woms2 woms1 woms0 write: 0x024f reserved read: 0 0 0 0 0 0 0 0 write: 0x0250 ptm read: 0 0 ptm5 ptm4 ptm3 ptm2 ptm1 ptm0 write: 0x0251 ptim read: 0 0 ptim5 ptim4 ptim3 ptim2 ptim1 ptim0 write: 0x0252 ddrm read: 0 0 ddrm5 ddrm4 ddrm3 ddrm2 ddrm1 ddrm0 write: 0x0253 rdrm read: 0 0 rdrm5 rdrm4 rdrm3 rdrm2 rdrm1 rdrm0 write: 0x0254 perm read: 0 0 perm5 perm4 perm3 perm2 perm1 perm0 write: 0x0255 ppsm read: 0 0 ppsm5 ppsm4 ppsm3 ppsm2 ppsm1 ppsm0 write:
chapter 1 mc9s12q device overview (mc9s12q128-family) 42 mc9s12q128 freescale semiconductor rev 1.09 0x0256 womm read: 0 0 womm5 womm4 womm3 womm2 womm1 womm0 write: 0x0257 reserved read: 0 0 0 0 0 0 0 0 write: 0x0258 ptp read: ptp7 ptp6 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 write: 0x0259 ptip read: ptip7 ptip6 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 write: 0x025a ddrp read: ddrp7 ddrp7 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 write: 0x025b rdrp read: rdrp7 rdrp6 rdrp5 rdrp4 rdrp3 rdrp2 rdrp1 rdrp0 write: 0x025c perp read: perp7 perp6 perp5 perp4 perp3 perp2 perp1 perp0 write: 0x025d ppsp read: ppsp7 ppsp6 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppss0 write: 0x025e piep read: piep7 piep6 piep5 piep4 piep3 piep2 piep1 piep0 write: 0x025f pifp read: pifp7 pifp6 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 write: 0x0260 reserved read: 0 0 0 0 0 0 0 0 write: 0x0261 reserved read: 0 0 0 0 0 0 0 0 write: 0x0262 reserved read: 0 0 0 0 0 0 0 0 write: 0x0263 reserved read: 0 0 0 0 0 0 0 0 write: 0x0264 reserved read: 0 0 0 0 0 0 0 0 write: 0x0265 reserved read: 0 0 0 0 0 0 0 0 write: 0x0266 reserved read: 0 0 0 0 0 0 0 0 write: 0x0267 reserved read: 0 0 0 0 0 0 0 0 write: 0x0268 ptj read: ptj7 ptj6 000000 write: 0x0269 ptij read: ptij7 ptij6 0 0 0 0 0 0 write: 0x026a ddrj read: ddrj7 ddrj7 000000 write: 0x026b rdrj read: rdrj7 rdrj6 000000 write: 0x026c perj read: perj7 perj6 000000 write: 0x0240?x027f pim (port interface module) (sheet 2 of 3) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 43 rev 1.09 0x026d ppsj read: ppsj7 ppsj6 000000 write: 0x026e piej read: piej7 piej6 000000 write: 0x026f pifj read: pifj7 pifj6 000000 write: 0x0270 ptad read: ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 write: 0x0271 ptiad read: ptiad7 ptiad6 ptiad5 ptiad4 ptiad3 ptiad2 ptiad1 ptij7 write: 0x0272 ddrad read: ddrad7 ddrad6 ddrad5 ddrad4 ddrad3 ddrad2 ddrad1 ddrad0 write: 0x0273 rdrad read: rdrad7 rdrad6 rdrad5 rdrad4 rdrad3 rdrad2 rdrad1 rdrad0 write: 0x0274 perad read: perad7 perad6 perad5 perad4 perad3 perad2 perad1 perad0 write: 0x0275 ppsad read: ppsad7 ppsad6 ppsad5 ppsad4 ppsad3 ppsad2 ppsad1 ppsad0 write: 0x0276- 0x027f reserved read: 0 0 0 0 0 0 0 0 write: 0x0280?x03ff reserved space address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0280 0x2ff reserved read: 0 0 0 0 0 0 0 0 write: 0x0300 ?x03ff unimplemented read: 0 0 0 0 0 0 0 0 write: 0x0240?x027f pim (port interface module) (sheet 3 of 3) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
chapter 1 mc9s12q device overview (mc9s12q128-family) 44 mc9s12q128 freescale semiconductor rev 1.09 1.2.3 part id assignments the part id is located in two 8-bit registers partidh and partidl (addresses 0x001a and ox001b after reset). the read-only value is a unique part id for each revision of the chip. table 1-3 shows the assigned part id numbers for production mask sets. the device memory sizes are located in two 8-bit registers memsiz0 and memsiz1 (addresses 0x001c and 0x001d after reset). table 1-4 shows the read-only values of these registers. refer to module mapping and control (mmc) block guide for further details. table 1-3. assigned part id numbers mc9s12q32 2l45j $3302 mc9s12q32 1m34c $3311 mc9s12q64, mc9s12q96, mc9s12q128 2l09s $3102 mc9s12q64, mc9s12q96, mc9s12q128 0m66g $3103 mc3s12q32 2l45j $3302 mc3s12q32 1m34c $3311 mc3s12q64, mc3s12q96, mc3s12q128 2l09s $3102 mc3s12q64, mc3s12q96, mc3s12q128 0m66g $3103 table 1-4. memory size registers device register name value mc9s12q32 memsiz0 $00 memsiz1 $80 mc9s12q64 memsiz0 $01 memsiz1 $c0 mc9s12q96 memsiz0 $01 memsiz1 $c0 mc9s12q128 memsiz0 $01 memsiz1 $c0
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 45 rev 1.09 1.3 signal description 1.3.1 device pinouts figure 1-6. pin assignments in 80-pin qfp the modrr register within the pim allows for mapping of pwm channels to port t in the absence of port p pins for the low pin count packages. for the 80qfp package option it is recommended not to use modrr since this is intended to support pwm channel availability in low pin count packages. note that when mapping pwm channels to port t in an 80qfp option, the associated pwm channels are then mapped to both port p and port t 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 mc9s12q128-family vrh vdda pad07/an07 pad06/an06 pad05/an05 pad04/an04 pad03/an03 pad02/an02 pad01/an01 pad00/an00 vss2 vdd2 pa7/addr15/data15 pa6/addr14/data14 pa5/addr13/data13 pa4/addr12/data12 pa3/addr11/data11 pa2/addr10/data10 pa1/addr9/data9 pa0/addr8/data8 pp4/kwp4 pp5/kwp5 pp7/kwp7 v ddx v ssx pm0/rxcan pm1/txcan pm2/miso pm3/ ss pm4/mosi pm5/sck pj6/kwj6 pj7/kwj7 pp6/kwp6/romctl ps3 ps2 ps1/txd ps0/rxd vssa vrl pw3/kwp3/pp3 pw2/kwp2/pp2 pw1/kwp1/pp1 pw0/kwp0/pp0 pw0/pt0 pw1/pt1 pw2/ioc2/pt2 pw3/ioc3/pt3 vdd1 vss1 ioc4/pt4 ioc5/pt5 ioc6/pt6 ioc7/pt7 modc/ t a ghi/bkgd addr0/data0/pb0 addr1/data1/pb1 addr2/data2/pb2 addr3/data3/pb3 addr4/data4/pb4 addr5/data5/pb5 addr6/data6/pb6 addr7/data7/pb7 xclks/noacc/pe7 modb/ipipe1/pe6 moda/ipipe0/pe5 eclk/pe4 vssr vddr reset vddpll xfc vsspll extal xtal test/vpp lstrb/ t a glo/pe3 r/ w/pe2 irq/pe1 xirq/pe0 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 signals shown in bold are not available on the 52 or 48 pin package signals shown in bold italic are available in the 52, but not the 48 pin package
chapter 1 mc9s12q device overview (mc9s12q128-family) 46 mc9s12q128 freescale semiconductor rev 1.09 figure 1-7. pin assignments in 52-pin lqfp mc9s12q128-family 1 2 3 4 5 6 7 8 9 10 11 12 13 39 38 37 36 35 34 33 32 31 30 29 28 27 14 15 16 17 18 19 20 21 22 23 24 25 26 52 51 50 49 48 47 46 45 44 43 42 41 40 * signals shown in bold italic are not available on the 48 pin package pp4/kwp4 pp5/kwp5 vddx vssx pm0/rxcan pm1/txcan pm2/miso pm3/ ss pm4/mosi pm5/sck ps1/txd ps0/rxd vssa vrh vdda pad07/an07 pad06/an06 pad05/an05 pad04/an04 pad03/an03 pad02/an02 pad01/an01 pad00/an00 pa2 pa1 pa0 xclks/pe7 eclk/pe4 vssr vddr reset vddpll xfc vsspll extal xtal test/vpp irq/pe1 xirq/pe0 pw3/kwp3/pp3 pw0/pt0 pw1/pt1 pw2/ioc2/pt2 pw3/ioc3/pt3 vdd1 vss1 ioc4/pt4 ioc5/pt5 ioc6/pt6 ioc7/pt7 modc/bkgd pb4
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 47 rev 1.09 figure 1-8. pin assignments in 48-pin lqfp mc9s12q128-family 1 2 3 4 5 6 7 8 9 10 11 12 36 35 34 33 32 31 30 29 28 27 26 25 13 14 15 16 17 18 19 20 21 22 23 24 48 47 46 45 44 43 42 41 40 39 38 37 pp5/kwp5 vddx vssx pm0/rxcan pm1/txcan pm2/miso pm3/ ss pm4/mosi pm5/sck ps1/txd ps0/rxd vssa pw0/pt0 pw1/pt1 pw2/ioc2/pt2 pw3/ioc3/pt3 vdd1 vss1 ioc4/pt4 ioc5/pt5 ioc6/pt6 ioc7/pt7 modc/bkgd pb4 xclks/pe7 eclk/pe4 vssr vddr reset vddpll xfc vsspll extal xtal test/vpp irq/pe1 vrh vdda pad07/an07 pad06/an06 pad05/an05 pad04/an04 pad03/an03 pad02/an02 pad01/an01 pad00/an00 pa0 xirq/pe0
chapter 1 mc9s12q device overview (mc9s12q128-family) 48 mc9s12q128 freescale semiconductor rev 1.09 1.3.2 signal properties summary table 1-5. signal properties pin name function 1 pin name function 2 pin name function 3 power domain internal pull resistor description ctrl reset state extal v ddpll na na oscillator pins xtal v ddpll na na reset v ddx none none external reset pin xfc v ddpll na na pll loop ?ter pin test v pp v ssx na na test pin only bkgd modc t a ghi v ddx up up background debug, mode pin, tag signal high pe7 noacc xclks v ddx pucr up port e i/o pin, access, clock select pe6 ipipe1 modb v ddx while reset pin is low: down port e i/o pin and pipe status pe5 ipipe0 moda v ddx while reset pin is low: down port e i/o pin and pipe status pe4 eclk v ddx pucr mode dep (1) port e i/o pin, bus clock output pe3 lstrb t a glo v ddx pucr mode dep 1 port e i/o pin, low strobe, tag signal low pe2 r/ wv ddx pucr mode dep 1 port e i/o pin, r/ w in expanded modes pe1 irq v ddx pucr up port e input, external interrupt pin pe0 xirq v ddx pucr up port e input, non-maskable interrupt pin pa[7:3] addr[15:1/ data[15:1] ? ddx pucr disabled port a i/o pin and multiplexed address/data pa[2:1] addr[10:9/ data[10:9] ? ddx pucr disabled port a i/o pin and multiplexed address/data pa[0] addr[8]/ data[8] ? ddx pucr disabled port a i/o pin and multiplexed address/data pb[7:5] addr[7:5]/ data[7:5] ? ddx pucr disabled port b i/o pin and multiplexed address/data pb[4] addr[4]/ data[4] ? ddx pucr disabled port b i/o pin and multiplexed address/data pb[3:0] addr[3:0]/ data[3:0] ? ddx pucr disabled port b i/o pin and multiplexed address/data pad[7:0] an[7:0] v dda perad/p psad disabled port ad i/o pins and atd inputs pp[7] kwp[7] v ddx perp/ ppsp disabled port p i/o pins and keypad wake-up pp[6] kwp[6] romctl v ddx perp/ ppsp disabled port p i/o pins, keypad wake-up, and romon enable. pp[5] kwp[5] pw5 v ddx perp/ ppsp disabled port p i/o pin, keypad wake-up, pw5 output pp[4:3] kwp[4:3] pw[3] v ddx perp/ ppsp disabled port p i/o pin, keypad wake-up, pwm output
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 49 rev 1.09 1.3.3 pin initialization for 48- and 52-pin lqfp bond out versions not bonded pins: if the port pins are not bonded out in the chosen package the user should initialize the registers to be inputs with enabled pull resistance to avoid excess current consumption. this applies to the following pins: (48lqfp): port a[7:1], port b[7:5], port b[3:0], porte[6,5,3,2], port p[7:6], portp[4:0], port j[7:6], ports[3:2] (52lqfp): port a[7:3], port b[7:5], port b[3:0], porte[6,5,3,2], port p[7:6], portp[2:0], port j[7:6], ports[3:2] pp[2:0] kwp[2:0] pw[2:0] v ddx perp/ ppsp disabled port p i/o pins, keypad wake-up, pwm outputs pj[7:6] kwj[7:6] v ddx perj/ ppsj disabled port j i/o pins and keypad wake-up pm5 sck v ddx perm/ ppsm up port m i/o pin and spi sck signal pm4 mosi v ddx perm/ ppsm up port m i/o pin and spi mosi signal pm3 ss v ddx perm/ ppsm up port m i/o pin and spi ss signal pm2 miso v ddx perm/ ppsm up port m i/o pin and spi miso signal pm1 txcan v ddx perm/ ppsm up port m i/o pin and can transmit signal pm0 rxcan v ddx perm/ ppsm up port m i/o pin and can receive signal ps[3:2] v ddx pers/ ppss up port s i/o pins ps1 txd v ddx pers/ ppss up port s i/o pin and sci transmit signal ps0 rxd v ddx pers/ ppss up port s i/o pin and sci receive signal pt[7:5] ioc[7:5] v ddx pert/ ppst disabled port t i/o pins shared with timer (tim) pt[4:0] ioc[4:2] pw[3:0] v ddx pert/ ppst disabled port t i/o pins shared with timer and pwm 1. the port e output buffer enable signal control at reset is determined by the pear register and is mode dependent. for example, in special test mode rdwe = lstre = 1 which enables the pe[3:2] output buffers and disables the pull-ups. refer to s12_mebi user guide for pear register details. table 1-5. signal properties (continued) pin name function 1 pin name function 2 pin name function 3 power domain internal pull resistor description ctrl reset state
chapter 1 mc9s12q device overview (mc9s12q128-family) 50 mc9s12q128 freescale semiconductor rev 1.09 1.3.4 detailed signal descriptions 1.3.4.1 extal, xtal ?oscillator pins extal and xtal are the crystal driver and external clock pins. on reset all the device clocks are derived from the extal input frequency. xtal is the crystal output. 1.3.4.2 reset ?external reset pin reset is an active low bidirectional control signal that acts as an input to initialize the mcu to a known start-up state. it also acts as an open-drain output to indicate that an internal failure has been detected in either the clock monitor or cop watchdog circuit. external circuitry connected to the reset pin should not include a large capacitance that would interfere with the ability of this signal to rise to a valid logic one within 32 eclk cycles after the low drive is released. upon detection of any reset, an internal circuit drives the reset pin low and a clocked reset sequence controls when the mcu can begin normal processing. 1.3.4.3 test / v pp ?test pin this pin is reserved for test and must be tied to v ss in all applications. 1.3.4.4 xfc ?pll loop filter pin dedicated pin used to create the pll loop ?ter. see crg bug for more detailed information.pll loop ?ter. please ask your motorola representative for the interactive application note to compute pll loop ?ter elements. any current leakage on this pin must be avoided. figure 1-9. pll loop filter connections 1.3.4.5 bkgd / t a ghi / modc ?background debug, tag high, and mode pin the bkgd / t a ghi / modc pin is used as a pseudo-open-drain pin for the background debug communication. in mcu expanded modes of operation when instruction tagging is on, an input low on this pin during the falling edge of e-clock tags the high half of the instruction word being read into the instruction queue. it is also used as a mcu operating mode select pin at the rising edge during reset, when the state of this pin is latched to the modc bit. mcu xfc r 0 c s c p v ddpll v ddpll
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 51 rev 1.09 1.3.4.6 pa[7:0] / addr[15:8] / data[15:8] ?port a i/o pins pa7?a0 are general purpose input or output pins,. in mcu expanded modes of operation, these pins are used for the multiplexed external address and data bus. pa[7:1] pins are not available in the 48-pin package version. pa[7:3] are not available in the 52-pin package version. 1.3.4.7 pb[7:0] / addr[7:0] / data[7:0] ?port b i/o pins pb7?b0 are general purpose input or output pins. in mcu expanded modes of operation, these pins are used for the multiplexed external address and data bus. pb[7:5] and pb[3:0] pins are not available in the 48-pin nor 52-pin package version. 1.3.4.8 pe7 / noacc / xclks ?port e i/o pin 7 pe7 is a general purpose input or output pin. during mcu expanded modes of operation, the noacc signal, when enabled, is used to indicate that the current bus cycle is an unused or ?ree cycle. this signal will assert when the cpu is not using the bus.the xclks is an input signal which controls whether a crystal in combination with the internal colpitts (low power) oscillator is used or whether pierce oscillator/external clock circuitry is used. the state of this pin is latched at the rising edge of reset. if the input is a logic low the extal pin is con?ured for an external clock drive or a pierce oscillator. if input is a logic high a colpitts oscillator circuit is con?ured on extal and xtal. since this pin is an input with a pull-up device during reset, if the pin is left ?ating, the default con?uration is a colpitts oscillator circuit on extal and xtal. figure 1-10. colpitts oscillator connections (pe7 = 1) figure 1-11. pierce oscillator connections (pe7 = 0) mcu c 2 extal xtal crystal or v sspll ceramic resonator c 1 cdc 1 1. due to the nature of a translated ground colpitts oscillator a dc voltage bias is applied to the crystal. please contact the crystal manufacturer for crystal dc. mcu extal xtal r s 1 r b v sspll crystal or ceramic resonator c 2 c 1 1. rs can be zero (shorted) when used with higher frequency crystals, refer to manufacturers data.
chapter 1 mc9s12q device overview (mc9s12q128-family) 52 mc9s12q128 freescale semiconductor rev 1.09 figure 1-12. external clock connections (pe7 = 0) 1.3.4.9 pe6 / modb / ipipe1 ?port e i/o pin 6 pe6 is a general purpose input or output pin. it is used as a mcu operating mode select pin during reset. the state of this pin is latched to the modb bit at the rising edge of reset. this pin is shared with the instruction queue tracking signal ipipe1. this pin is an input with a pull-down device which is only active when reset is low. pe[6] is not available in the 48- / 52-pin package versions. 1.3.4.10 pe5 / moda / ipipe0 ?port e i/o pin 5 pe5 is a general purpose input or output pin. it is used as a mcu operating mode select pin during reset. the state of this pin is latched to the moda bit at the rising edge of reset. this pin is shared with the instruction queue tracking signal ipipe0. this pin is an input with a pull-down device which is only active when reset is low. this pin is not available in the 48- / 52-pin package versions. 1.3.4.11 pe4 / eclk?port e i/o pin [4] / e-clock output eclk is the output connection for the internal bus clock. it is used to demultiplex the address and data in expanded modes and is used as a timing reference. eclk frequency is equal to 1/2 the crystal frequency out of reset. the eclk pin is initially con?ured as eclk output with stretch in all expanded modes. the e clock output function depends upon the settings of the neclk bit in the pear register, the ivis bit in the mode register and the estr bit in the ebictl register. all clocks, including the e clock, are halted when the mcu is in stop mode. it is possible to con?ure the mcu to interface to slow external memory. eclk can be stretched for such accesses. reference the misc register (exstr[1:0] bits) for more information. in normal expanded narrow mode, the e clock is available for use in external select decode logic or as a constant speed clock for use in the external application system. alternatively pe4 can be used as a general purpose input or output pin. 1.3.4.12 pe3 / lstrb ?port e i/o pin [3] / low-byte strobe ( lstrb) in all modes this pin can be used as a general-purpose i/o and is an input with an active pull-up out of reset. if the strobe function is required, it should be enabled by setting the lstre bit in the pear register. this signal is used in write operations. therefore external low byte writes will not be possible until this function is enabled. this pin is also used as t a glo in special expanded modes and is multiplexed with the lstrb function. this pin is not available in the 48- / 52-pin package versions. mcu extal xtal not connected cmos compatible external oscillator (v ddpll level)
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 53 rev 1.09 1.3.4.13 pe2 / r / w ?port e i/o pin [2] / read/write in all modes this pin can be used as a general-purpose i/o and is an input with an active pull-up out of reset. if the read/write function is required it should be enabled by setting the rdwe bit in the pear register. external writes will not be possible until enabled. this pin is not available in the 48- / 52-pin package versions. 1.3.4.14 pe1 / irq ?port e input pin [1] / maskable interrupt pin the irq input provides a means of applying asynchronous interrupt requests to the mcu. either falling edge-sensitive triggering or level-sensitive triggering is program selectable (intcr register). irq is always enabled and con?ured to level-sensitive triggering out of reset. it can be disabled by clearing irqen bit (intcr register). when the mcu is reset the irq function is masked in the condition code register. this pin is always an input and can always be read. there is an active pull-up on this pin while in reset and immediately out of reset. the pull-up can be turned off by clearing pupee in the pucr register. 1.3.4.15 pe0 / xirq ?port e input pin [0] / non maskable interrupt pin the xirq input provides a means of requesting a non-maskable interrupt after reset initialization. during reset, the x bit in the condition code register (ccr) is set and any interrupt is masked until mcu software enables it. because the xirq input is level sensitive, it can be connected to a multiple-source wired-or network. this pin is always an input and can always be read. there is an active pull-up on this pin while in reset and immediately out of reset. the pull-up can be turned off by clearing pupee in the pucr register. 1.3.4.16 pad[7:0] / an[7:0] ?port ad i/o pins [7:0] pad7?ad0 are general purpose i/o pins and also analog inputs for the analog to digital converter. in order to use a pad pin as a standard input, the corresponding atddien register bit must be set. these bits are cleared out of reset to con?ure the pad pins for a/d operation. when the a/d converter is active in multi-channel mode, port inputs are scanned and converted irrespective of port ad con?uration. thus port ad pins that are con?ured as digital inputs or digital outputs are also converted in the a/d conversion sequence. 1.3.4.17 pp[7] / kwp[7] ?port p i/o pin [7] pp7 is a general purpose input or output pin, shared with the keypad interrupt function. when con?ured as an input, it can generate interrupts causing the mcu to exit stop or wait mode. this pin is not available in the 48- / 52-pin package versions. 1.3.4.18 pp[6] / kwp[6]/romctl ?port p i/o pin [6] pp6 is a general purpose input or output pin, shared with the keypad interrupt function. when con?ured as an input, it can generate interrupts causing the mcu to exit stop or wait mode. this pin is not available in the 48- / 52-pin package versions. during mcu expanded modes of operation, this pin is used to enable
chapter 1 mc9s12q device overview (mc9s12q128-family) 54 mc9s12q128 freescale semiconductor rev 1.09 the flash eeprom memory in the memory map (romctl). at the rising edge of reset, the state of this pin is latched to the romon bit. pp6 = 1 in emulation modes equates to romon = 0 (rom space externally mapped) pp6 = 0 in expanded modes equates to romon = 0 (rom space externally mapped) 1.3.4.19 pp[5:0] / kwp[5:0] / pw[3:0] ?port p i/o pins [5:0] pp[5:0] are general purpose input or output pins, shared with the keypad interrupt function. when con?ured as inputs, they can generate interrupts causing the mcu to exit stop or wait mode. pp[3:0] are also shared with the pwm output signals, pw[3:0].pins pp[2:0] are only available in the 80- pin package version. pins pp[4:3] are not available in the 48-pin package version. 1.3.4.20 pj[7:6] / kwj[7:6] ?port j i/o pins [7:6] pj[7:6] are general purpose input or output pins, shared with the keypad interrupt function. when con?ured as inputs, they can generate interrupts causing the mcu to exit stop or wait mode. these pins are not available in the 48-pin package version nor in the 52-pin package version. 1.3.4.21 pm5 / sck ?port m i/o pin 5 pm5 is a general purpose input or output pin and also the serial clock pin sck for the serial peripheral interface (spi). 1.3.4.22 pm4 / mosi ?port m i/o pin 4 pm4 is a general purpose input or output pin and also the master output (during master mode) or slave input (during slave mode) pin for the serial peripheral interface (spi). 1.3.4.23 pm3 / ss ?port m i/o pin 3 pm3 is a general purpose input or output pin and also the slave select pin ss for the serial peripheral interface (spi). 1.3.4.24 pm2 / miso ?port m i/o pin 2 pm2 is a general purpose input or output pin and also the master input (during master mode) or slave output (during slave mode) pin for the serial peripheral interface (spi). 1.3.4.25 pm1 / txcan ?port m i/o pin 1 pm1 is a general purpose input or output pin and the transmit pin, txcan, of the can module if available. 1.3.4.26 pm0 / rxcan ?port m i/o pin 0 pm0 is a general purpose input or output pin and the receive pin, rxcan, of the can module if available.
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 55 rev 1.09 1.3.4.27 ps[3:2] ?port s i/o pins [3:2] ps3 and ps2 are general purpose input or output pins. these pins are not available in the 48- / 52-pin package versions. 1.3.4.28 ps1 / txd ?port s i/o pin 1 ps1 is a general purpose input or output pin and the transmit pin, txd, of serial communication interface (sci). 1.3.4.29 ps0 / rxd ?port s i/o pin 0 ps0 is a general purpose input or output pin and the receive pin, rxd, of serial communication interface (sci). 1.3.4.30 pt[7:5] / ioc[7:5] ?port t i/o pins [7:5] pt7?t5 are general purpose input or output pins. they can also be con?ured as the timer system input capture or output compare pins ioc7-ioc5. 1.3.4.31 pt[4:0] / ioc[4: 2 ] / pw[ 3 :0]?port t i/o pins [4:0] pt4?t0 are general purpose input or output pins. they can also be con?ured as the timer system input capture or output compare pins ioc[n] or as the pwm outputs pw[n]. 1.3.5 power supply pins 1.3.5.1 v ddx ,v ssx ?power and ground pins for i/o drivers external power and ground for i/o drivers. bypass requirements depend on how heavily the mcu pins are loaded. 1.3.5.2 v ddr , v ssr ?power and ground pins for i/o drivers and for internal voltage regulator external power and ground for the internal voltage regulator. connecting v ddr to ground disables the internal voltage regulator. 1.3.5.3 v dd1 , v dd2 , v ss1 , v ss2 ?internal logic power pins power is supplied to the mcu through v dd and v ss . this 2.5v supply is derived from the internal voltage regulator. there is no static load on those pins allowed. the internal voltage regulator is turned off, if v ddr is tied to ground.
chapter 1 mc9s12q device overview (mc9s12q128-family) 56 mc9s12q128 freescale semiconductor rev 1.09 1.3.5.4 v dda , v ssa ?power supply pins for atd and vreg v dda ,v ssa are the power supply and ground input pins for the voltage regulator reference and the analog to digital converter. 1.3.5.5 v rh , v rl ?atd reference voltage input pins v rh and v rl are the reference voltage input pins for the analog to digital converter. 1.3.5.6 v ddpll , v sspll ?power supply pins for pll provides operating voltage and ground for the oscillator and the phased-locked loop. this allows the supply voltage to the oscillator and pll to be bypassed independently. this 2.5v voltage is generated by the internal voltage regulator. note all v ss pins must be connected together in the application. because fast signal transitions place high, short-duration current demands on the power supply, use bypass capacitors with high-frequency characteristics and place them as close to the mcu as possible. bypass requirements depend on mcu pin load. table 1-6. power and ground connection summary mnemonic nominal voltage (v) description v dd1, vdd2 2.5 internal power and ground generated by internal regulator. these also allow an external source to supply the core v dd /v ss voltages and bypass the internal voltage regulator. in the 48 and 52 lqfp packages v dd2 and v ss2 are not available. v ss1, vss2 0 v ddr 5.0 external power and ground, supply to internal voltage regulator. v ssr 0 v ddx 5.0 external power and ground, supply to pin drivers. v ssx 0 v dda 5.0 operating voltage and ground for the analog-to-digital converters and the reference for the internal voltage regulator, allows the supply voltage to the a/d to be bypassed independently. v ssa 0 v rh 5.0 reference voltage low for the atd converter. in the 48 and 52 lqfp packages v rl is bonded to v ssa . v rl 0 v ddpll 2.5 provides operating voltage and ground for the phased-locked loop. this allows the supply voltage to the pll to be bypassed independently. internal power and ground generated by internal regulator. v sspll 0
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 57 rev 1.09 1.4 system clock description the clock and reset generator provides the internal clock signals for the core and all peripheral modules. figure 1-13 shows the clock connections from the crg to all modules. consult the crg block user guide for details on clock generation. figure 1-13. clock connections 1.5 modes of operation eight possible modes determine the device operating con?uration. each mode has an associated default memory map and external bus con?uration controlled by a further pin. three low power modes exist for the device. 1.5.1 chip con?uration summary the operating mode out of reset is determined by the states of the modc, modb, and moda pins during reset. the modc, modb, and moda bits in the mode register show the current operating mode and provide limited mode switching during operation. the states of the modc, modb, and moda pins are latched into these bits on the rising edge of the reset signal. the romctl signal allows the setting of the romon bit in the misc register thus controlling whether the internal flash is visible in the memory map. romon = 1 mean the flash is visible in the memory map. the state of the romctl pin is latched into the romon bit in the misc register on the rising edge of the reset signal. crg bus clock core clock extal xtal oscillator clock s12_core vreg ram sci atd flash tim tpm spi mscan pim not on 9s12gc
chapter 1 mc9s12q device overview (mc9s12q128-family) 58 mc9s12q128 freescale semiconductor rev 1.09 for further explanation on the modes refer to the s12_mebi block guide. 1.5.2 security the device will make available a security feature preventing the unauthorized read and write of the memory contents. this feature allows: protection of the contents of flash, operation in single-chip mode, operation from external memory with internal flash disabled. the user must be reminded that part of the security must lie with the users code. an extreme example would be users code that dumps the contents of the internal program. this code would defeat the purpose of security. at the same time the user may also wish to put a back door in the users program. an example of this is the user downloads a key through the sci which allows access to a programming routine that updates parameters. 1.5.2.1 securing the microcontroller once the user has programmed the flash, the part can be secured by programming the security bits located in the flash module. these non-volatile bits will keep the part secured through resetting the part and through powering down the part. table 1-7. mode selection bkgd = modc pe6 = modb pe5 = moda pp6 = romctl romon bit mode description 000 x 1 special single chip, bdm allowed and active. bdm is allowed in all other modes but a serial command is required to make bdm active. 001 0 1 emulation expanded narrow, bdm allowed 10 0 1 0 x 0 special test (expanded wide), bdm allowed 011 0 1 emulation expanded wide, bdm allowed 10 1 0 0 x 1 normal single chip, bdm allowed 101 0 0 normal expanded narrow, bdm allowed 11 110 x 1 peripheral; bdm allowed but bus operations would cause bus con?cts (must not be used) 111 0 0 normal expanded wide, bdm allowed 11 table 1-8. clock selection based on pe7 pe7 = xclks description 1 colpitts oscillator selected 0 pierce oscillator/external clock selected
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 59 rev 1.09 the security byte resides in a portion of the flash array. check the flash block user guide for more details on the security con?uration. 1.5.2.2 operation of the secured microcontroller 1.5.2.2.1 normal single chip mode this will be the most common usage of the secured part. everything will appear the same as if the part was not secured with the exception of bdm operation. the bdm operation will be blocked. 1.5.2.2.2 executing from external memory the user may wish to execute from external space with a secured microcontroller. this is accomplished by resetting directly into expanded mode. the internal flash will be disabled. bdm operations will be blocked. 1.5.2.3 unsecuring the microcontroller in order to unsecure the microcontroller, the internal flash must be erased. this can be done through an external program in expanded mode or via a sequence of bdm commands. unsecuring is also possible via the backdoor key access. refer to flash block guide for details. once the user has erased the flash, the part can be reset into special single chip mode. this invokes a program that veri?s the erasure of the internal flash. once this program completes, the user can erase and program the flash security bits to the unsecured state. this is generally done through the bdm, but the user could also change to expanded mode (by writing the mode bits through the bdm) and jumping to an external program (again through bdm commands). note that if the part goes through a reset before the security bits are reprogrammed to the unsecure state, the part will be secured again. 1.5.3 low-power modes the microcontroller features three main low power modes. consult the respective block user guide for information on the module behavior in stop, pseudo stop, and wait mode. an important source of information about the clock system is the clock and reset generator user guide (crg). 1.5.3.1 stop executing the cpu stop instruction stops all clocks and the oscillator thus putting the chip in fully static mode. wake up from this mode can be done via reset or external interrupts. 1.5.3.2 pseudo stop this mode is entered by executing the cpu stop instruction. in this mode the oscillator is still running and the real time interrupt (rti) or watchdog (cop) sub module can stay active. other peripherals are turned off. this mode consumes more current than the full stop mode, but the wake up time from this mode is signi?antly shorter.
chapter 1 mc9s12q device overview (mc9s12q128-family) 60 mc9s12q128 freescale semiconductor rev 1.09 1.5.3.3 wait this mode is entered by executing the cpu wai instruction. in this mode the cpu will not execute instructions. the internal cpu signals (address and data bus) will be fully static. all peripherals stay active. for further power consumption reduction the peripherals can individually turn off their local clocks. 1.5.3.4 run although this is not a low-power mode, unused peripheral modules should not be enabled in order to save power. 1.6 resets and interrupts consult the exception processing section of the cpu12 reference manual for information. 1.6.1 vectors table 1-9 lists interrupt sources and vectors in default order of priority. table 1-9. interrupt vector locations vector address interrupt source ccr mask local enable hprio value to elevate 0xfffe, 0xffff external reset, power on reset, or low voltage reset (see crg ?gs register to determine reset source) none none 0xfffc, 0xfffd clock monitor fail reset none copctl (cme, fcme) 0xfffa, 0xfffb cop failure reset none cop rate select 0xfff8, 0xfff9 unimplemented instruction trap none none 0xfff6, 0xfff7 swi none none 0xfff4, 0xfff5 xirq x-bit none 0xfff2, 0xfff3 irq i bit intcr (irqen) 0x00f2 0xfff0, 0xfff1 real time interrupt i bit crgint (rtie) 0x00f0 $ffee, $ffef reserved $ffec, $ffed reserved 0xffea, 0xffeb standard timer channel 2 i bit tie (c2i) 0x00ea 0xffe8, 0xffe9 standard timer channel 3 i bit tie (c3i) 0x00e8 0xffe6, 0xffe7 standard timer channel 4 i bit tie (c4i) 0x00e6 0xffe4, 0xffe5 standard timer channel 5 i bit tie (c5i) 0x00e4 0xffe2, 0xffe3 standard timer channel 6 i bit tie (c6i) 0x00e2 0xffe0, 0xffe1 standard timer channel 7 i bit tie (c7i) 0x00e0 0xffde, 0xffdf standard timer over?w i bit tmsk2 (toi) 0x00de 0xffdc, 0xffdd pulse accumulator a over?w i bit pactl (paovi) 0x00dc
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 61 rev 1.09 0xffda, 0xffdb pulse accumulator input edge i bit pactl (pai) 0x00da 0xffd8, 0xffd9 spi i bit spicr1 (spie, sptie) 0x00d8 0xffd6, 0xffd7 sci i bit scicr2 (tie, tcie, rie, ilie) 0x00d6 0xffd4, 0xffd5 reserved 0xffd2, 0xffd3 atd i bit atdctl2 (ascie) 0x00d2 0xffd0, 0xffd1 reserved 0xffce, 0xffcf port j i bit piep (piep7-6) 0x00ce 0xffcc, 0xffcd reserved 0xffca, 0xffcb reserved 0xffc8, 0xffc9 reserved 0xffc6, 0xffc7 crg pll lock i bit pllcr (lockie) 0x00c6 0xffc4, 0xffc5 crg self clock mode i bit pllcr (scmie) 0x00c4 0xffba to 0xffc3 reserved 0xffb8, 0xffb9 flash i bit fcnfg (ccie, cbeie) 0x00b8 0xffb6, 0xffb7 can wake-up i bit canrier (wupie) 0x00b6 0xffb4, 0xffb5 can errors i bit canrier (cscie, ovrie) 0x00b4 0xffb2, 0xffb3 can receive i bit canrier (rxfie) 0x00b2 0xffb0, 0xffb1 can transmit i bit cantier (txeie[2:0]) 0x00b0 0xff90 to 0xffaf reserved 0xff8e, 0xff8f port p i bit piep (piep7-0) 0x008e 0xff8c, 0xff8d reserved 0xff8a, 0xff8b vreg lvi i bit ctrl0 (lvie) 0x008a 0xff80 to 0xff89 reserved table 1-9. interrupt vector locations (continued) vector address interrupt source ccr mask local enable hprio value to elevate
chapter 1 mc9s12q device overview (mc9s12q128-family) 62 mc9s12q128 freescale semiconductor rev 1.09 1.6.2 resets resets are a subset of the interrupts featured in table 1-9 . the different sources capable of generating a system reset are summarized in table 1-10 . when a reset occurs, mcu registers and control bits are changed to known start-up states. refer to the respective module block user guides for register reset states. 1.6.2.1 reset summary table 1.6.2.2 effects of reset when a reset occurs, mcu registers and control bits are changed to known start-up states. refer to the respective module block user guides for register reset states. refer to the hcs12 multiplexed external bus interface (mebi) block guide for mode dependent pin con?uration of port a, b and e out of reset. refer to the pim block user guide for reset con?urations of all peripheral module ports. refer to figure 1-2. to figure 1-5. footnotes for locations of the memories depending on the operating mode after reset. the ram array is not automatically initialized out of reset. note for devices assembled in 48-pin or 52-pin lqfp packages all non-bonded out pins should be con?ured as outputs after reset in order to avoid current drawn from ?ating inputs. refer to table 1-5 for affected pins. 1.7 device speci? information and module dependencies 1.7.1 ppage external paging is not supported on these devices. in order to access the 16k ?sh blocks in the address range 0x8000?xbfff the ppage register must be loaded with the corresponding value for this range. refer to table 1-11 for device speci? page mapping. for all devices flash page 3f is visible in the 0xc000?xffff range if romon is set. for all devices (except mc9s12gc16) page 3e is also visible in the 0x4000?x7fff range if romhm is cleared and romon is set. for all devices apart from mc9s12q32 flash page 3d is visible in the 0x0000?x3fff range if romon is set... table 1-10. reset summary reset priority source vector power-on reset 1 crg module 0xfffe, 0xffff external reset 1 reset pin 0xfffe, 0xffff low voltage reset 1 vreg module 0xfffe, 0xffff clock monitor reset 2 crg module 0xfffc, 0xfffd cop watchdog reset 3 crg module 0xfffa, 0xfffb
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 63 rev 1.09 1.7.2 bdm alternate clock the bdm section reference to alternate clock is equivalent to the oscillator clock. 1.7.3 extended address range emulation implications in order to emulate the devices, external addressing of a 128k memory map is required. this is provided in a 112 lqfp package version which includes the 3 necessary extra external address bus signals via portk[2:0]. this package version is for emulation only and not provided as a general production package. the reset state of ddrk is 0x0000, con?uring the pins as inputs. the reset state of pupke in the pucr register is ??enabling the internal port k pullups. in this reset state the pull-ups provide a de?ed state and prevent a ?ating input, thereby preventing unnecessary current ?w at the input stage. to prevent unnecessary current ?w in production package options, the states of ddrk and pupke should not be changed by software. table 1-11. device speci? flash page mapping device page page visible with ppage contents mc9s12q32 3e $00,$02,$04,$06,$08,$0a,$0c,$0e,$10,$12......$2c,$2e,$30,$32,$34,$36,$38,$3a,$3c,$3e 3f $01,$03,$05,$07,$09,$0b,$0d,$0f,$11,$13.....$2d,$2f,$31,$33,$35,$37,$39,$3b,$3d,$3f mc9s12q64 3c $04,$0c,$14,$1c,$24,$2c,$34,$3c 3d $05,$0d,$15,$1d,$25,$2d,$35,$3d 3e $06,$0e,$16,$1e,$26,$2e,$36,$3e 3f $07,$0f,$17,$1f,$27,$2f,$37,$3f mc9s12q96 3a $02,$0a,$12,$1a,$22,$2a,$32,$3a 3b $03,$0b,$13,$1b,$23,$2b,$33,$3b 3c $04,$0c,$14,$1c,$24,$2c,$34,$3c 3d $05,$0d,$15,$1d,$25,$2d,$35,$3d 3e $06,$0e,$16,$1e,$26,$2e,$36,$3e 3f $07,$0f,$17,$1f,$27,$2f,$37,$3f mc9s12q128 38 $00,$08,$10,$18,$20,$28,$30,$38 39 $01,$09,$11,$19,$21,$29,$31,$39 3a $02,$0a,$12,$1a,$22,$2a,$32,$3a 3b $03,$0b,$13,$1b,$23,$2b,$33,$3b 3c $04,$0c,$14,$1c,$24,$2c,$34,$3c 3d $05,$0d,$15,$1d,$25,$2d,$35,$3d 3e $06,$0e,$16,$1e,$26,$2e,$36,$3e 3f $07,$0f,$17,$1f,$27,$2f,$37,$3f
chapter 1 mc9s12q device overview (mc9s12q128-family) 64 mc9s12q128 freescale semiconductor rev 1.09 1.7.4 vregen the vregen input mentioned in the vreg section is device internal, connected internally to v ddr . 1.7.5 v dd1 , v dd2 , v ss1 , v ss2 in the 80-pin qfp package versions, both internal v dd and v ss of the 2.5v domain are bonded out on 2 sides of the device as two pin pairs (v dd1 ,v ss1 &v dd2 ,v ss2 ). v dd1 and v dd2 are connected together internally. v ss1 and v ss2 are connected together internally. the extra pin pair enables systems using the 80-pin package to employ better supply routing and further decoupling. 1.7.6 clock reset generator and vreg interface the low voltage reset feature uses the low voltage reset signal from the vreg module as an input to the crg module. when the regulator output voltage supply to the internal chip logic falls below a speci?d threshold the lvr signal from the vreg module causes the crg module to generate a reset. note if the voltage regulator is shut down by connecting v ddr to ground then the lvrf ?g in the crg ?gs register (crgflg) is unde?ed. 1.7.7 analog-to-digital converter in the 48- and 52-pin package versions, the v rl pad is bonded internally to the v ssa pin. 1.7.8 modrr register port t and port p mapping the modrr register within the pim allows for mapping of pwm channels to port t in the absence of port p pins for the low pin count packages. for the 80qfp package option it is recommended not to use modrr since this is intended to support pwm channel availability in low pin count packages. note that when mapping pwm channels to port t in an 80qfp option, the associated pwm channels are then mapped to both port p and port t. modrr[4] must not be set for. 1.7.9 port ad dependency on pim and atd registers the port ad pins interface to the pim module. however, the port pin digital state can be read from either the portad register in the atd register map or from the ptad register in the pim register map. in order to read a digital pin value from portad the corresponding atddien bit must be set and the corresponding ddrda bit cleared. if the corresponding atddien bit is cleared then the pin is con?ured as an analog input and the portad bit reads back as "1". in order to read a digital pin value from ptad, the corresponding ddrad bit must be cleared, to con?ure the pin as an input. furthermore in order to use a port ad pin as an analog input, the corresponding ddrad bit must be cleared to con?ure the pin as an input
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 65 rev 1.09 1.8 recommended printed circuit board layout the pcb must be carefully laid out to ensure proper operation of the voltage regulator as well as of the mcu itself. the following rules must be observed: every supply pair must be decoupled by a ceramic capacitor connected as near as possible to the corresponding pins. central point of the ground star should be the v ssr pin. use low ohmic low inductance connections between v ss1 , v ss2 , and v ssr . ? sspll must be directly connected to v ssr . keep traces of v sspll , extal, and xtal as short as possible and occupied board area for c6, c7, c11, and q1 as small as possible. do not place other signals or supplies underneath area occupied by c6, c7, c5, and q1 and the connection area to the mcu. central power input should be fed in at the v dda /v ssa pins. table 1-12. recommended component values component purpose type value c1 v dd1 ?ter capacitor ceramic x7r 220nf, 470nf (1) 1. in 48lqfp and 52lqfp package versions, v dd2 is not available. thus 470nf must be connected to v dd1 . c2 v ddr ?ter capacitor x7r/tantalum >=100nf c3 v ddpll ?ter capacitor ceramic x7r 100nf c4 pll loop ?ter capacitor see pll speci?ation chapter c5 pll loop ?ter capacitor c6 osc load capacitor see pll speci?ation chapter c7 osc load capacitor c8 v dd2 ?ter capacitor (80 qfp only) ceramic x7r 220nf c9 v dda ?ter capacitor ceramic x7r 100nf c10 v ddx ?ter capacitor x7r/tantalum >=100nf c11 dc cutoff capacitor colpitts mode only, if recommended by quartz manufacturer r1 pierce mode select pullup pierce mode only r2 pll loop ?ter resistor see pll speci?ation chapter r3 / r b pll loop ?ter resistor pierce mode only r4 / r s pll loop ?ter resistor q1 quartz
chapter 1 mc9s12q device overview (mc9s12q128-family) 66 mc9s12q128 freescale semiconductor rev 1.09 figure 1-14. recommended pcb layout (48 lqfp) colpitts oscillator
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 67 rev 1.09 figure 1-15. recommended pcb layout (52 lqfp) colpitts oscillator
chapter 1 mc9s12q device overview (mc9s12q128-family) 68 mc9s12q128 freescale semiconductor rev 1.09 figure 1-16. recommended pcb layout (80 qfp) colpitts oscillator
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 69 rev 1.09 figure 1-17. recommended pcb layout for 48 lqfp pierce oscillator
chapter 1 mc9s12q device overview (mc9s12q128-family) 70 mc9s12q128 freescale semiconductor rev 1.09 figure 1-18. recommended pcb layout for 52 lqfp pierce oscillator
chapter 1 mc9s12q device overview (mc9s12q128-family) freescale semiconductor mc9s12q128 71 rev 1.09 figure 1-19. recommended pcb layout for 80qfp pierce oscillator
chapter 1 mc9s12q device overview (mc9s12q128-family) 72 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 73 rev 1.09 chapter 2 port integration module (pim9c32) block description 2.1 introduction the port integration module establishes the interface between the peripheral modules and the i/o pins for all ports. this chapter covers: port a, b, and e related to the core logic and the multiplexed bus interface port t connected to the tim module (pwm module can be routed to port t as well) port s connected to the sci module port m associated to the mscan and spi module port p connected to the pwm module, external interrupt sources available port j pins can be used as external interrupt sources and standard i/os the following i/o pin configurations can be selected: available on all i/o pins: input/output selection drive strength reduction enable and select of pull resistors available on all port p and port j pins: interrupt enable and status ?gs the implementation of the port integration module is device dependent. 2.1.1 features a standard port has the following minimum features: input/output selection 5-v output drive with two selectable drive strength 5-v digital and analog input input with selectable pull-up or pull-down device optional features: open drain for wired-or connections interrupt inputs with glitch ?tering
chapter 2 port integration module (pim9c32) block description 74 mc9s12q128 freescale semiconductor rev 1.09 2.1.2 block diagram figure 2-1 is a block diagram of the pim. figure 2-1. pim block diagram note: the modrr register within the pim allows for mapping of pwm channels to port t in the absence of port p pins for the low pin count packages. for the 80qfp package option it is recommended not to use modrr since this is intended to support pwm channel availability in low pin count packages. note that when mapping pwm channels to port t in an 80qfp option, the associated pwm channels are then mapped to both port p and port t. port t pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 tim ioc2 ioc3 ioc4 ioc5 ioc6 ioc7 port p pp0 pp1 pp2 pp3 pp4 pp5 pp6 pp7 port s ps0 ps1 pm2 pm3 pm4 pm5 pm0 pm1 rxd txd rxcan txcan miso mosi sck ss sci can spi port j pj7 port integration module irq logic interrupt logic port b pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 port a pa 0 pa 1 pa 2 pa 3 pa 4 pa 5 pa 6 pa 7 port e pe0 pe1 pe2 pe3 pe4 pe5 pe6 pe7 addr8/data8 addr9/data9 addr10/data10 addr11/data11 addr12/data12 addr13/data13 addr14/data14 addr15/data15 addr0/data0 addr1/data1 addr2/data2 addr3/data3 addr4/data4 addr5/data5 addr6/data6 addr7/data7 xirq irq r/ w lstrb/ t a glo eclk ipipe0/moda noacc/ xclks ipipe1/modb core bkgd/modc/ t a ghi bkgd pj6 port m a/d pad0 pad1 pad2 pad3 pad4 pad5 pad6 pad7 at d an0 an1 an2 an3 an4 an5 an6 an7 ps2 ps3 pwm pwm0 pwm1 pwm2 pwm3 mux
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 75 rev 1.09 2.2 signal description this section lists and describes the signals that do connect off-chip. table 2-1 shows all pins and their functions that are controlled by the pim module. if there is more than one function associated to a pin, the priority is indicated by the position in the table from top (highest priority) to down (lowest priority). table 2-1. pin functions and priorities port pin name pin function description pin function after reset port t pt[7:0] pwm[3:0] pwm outputs (only available if enabled in modrr register) gpio ioc[7:2] standard timer channels gpio general-purpose i/o port s ps3 gpio general-purpose i/o ps2 gpio general purpose i/o ps1 txd serial communication interface transmit pin gpio general-purpose i/o ps0 rxd serial communication interface receive pin gpio general-purpose i/o port m pm5 sck spi clock pm4 mosi spi transmit pin pm3 ss spi slave select line pm2 miso spi receive pin pm1 txcan mscan transmit pin pm0 rxcan mscan receive pin port p pp[7:0] pwm[3:0] pwm outputs gpio[7:0] general purpose i/o with interrupt pp[6] romon romon input signal port j pj[7:6] gpio general purpose i/o with interrupt port ad pad[7:0] atd[7:0] atd analog inputs gpio[7:0] general purpose i/o port a pa[7:0] addr[15:8]/ data[15:8]/ gpio refer to mebi block guide. port b pb[7:0] addr[7:0]/ data[7:0]/ gpio refer to mebi block guide.
chapter 2 port integration module (pim9c32) block description 76 mc9s12q128 freescale semiconductor rev 1.09 2.3 memory map and registers this section provides a detailed description of all registers. 2.3.1 module memory map figure 2-2 shows the register map of the port integration module. port e pe7 noacc/ xclks/ gpio refer to mebi block guide. pe6 ipipe1/ modb/ gpio pe5 ipipe0/ moda/ gpio pe4 eclk/gpio pe3 lstrb/ t a glo/ gpio pe2 r/ w/ gpio pe1 irq/gpi pe0 xirq/gpi address name bit 7 654321 bit 0 0x0000 ptt r ptt7 ptt6 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w tim ioc7 ioc6 ioc5 ioc4 ioc3 ioc2 pwm pwm3 pwm2 pwm1 pwm0 0x0001 ptit r ptit7 ptit6 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w 0x0002 ddrt r ddrt7 ddrt6 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w 0x0003 rdrt r rdrt7 rdrt6 rdrt5 rdrt4 rdrt3 rdrt2 rdrt1 rdrt0 w 0x0004 pert r pert7 pert6 pert5 pert4 pert3 pert2 pert1 pert0 w 0x0005 ppst r ppst7 ppst6 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w = unimplemented or reserved figure 2-2. quick reference to pim registers (sheet 1 of 3) table 2-1. pin functions and priorities (continued) port pin name pin function description pin function after reset
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 77 rev 1.09 0x0006 reserved r00000000 w 0x0007 modrr r000 modrr4 modrr3 modrr2 modrr1 modrr0 w 0x0008 pts r0000 pts3 pts2 pts1 pts0 w scitxdrxd 0x0009 ptis r0000 ptis3 ptis2 ptis1 ptis0 w 0x000a ddrs r0000 ddrs3 ddrs2 ddrs1 ddrs0 w 0x000b rdrs r0000 rdrs3 rdrs2 rdrs1 rdrs0 w 0x000c pers r0000 pers3 pers2 pers1 pers0 w 0x000d ppss r0000 ppss3 ppss2 ppss1 ppss0 w 0x000e woms r0000 woms3 woms2 woms1 woms0 w 0x000f reserved r00000000 w 0x0010 ptm r0 0 ptm5 ptm4 ptm3 ptm2 ptm1 ptm0 w mscan / spi sck mosi ss miso txcan rxcan 0x0011 ptim r 0 0 ptim5 ptim4 ptim3 ptim2 ptim1 ptim0 w 0x0012 ddrm r0 0 ddrm5 ddrm4 ddrm3 ddrm2 ddrm1 ddrm0 w 0x0013 rdrm r0 0 rdrm5 rdrm4 rdrm3 rdrm2 rdrm1 rdrm0 w 0x0014 perm r0 0 perm5 perm4 perm3 perm2 perm1 perm0 w 0x0015 ppsm r0 0 ppsm5 ppsm4 ppsm3 ppsm2 ppsm1 ppsm0 w 0x0016 womm r0 0 womm5 womm4 womm3 womm2 womm1 womm0 w 0x0017 reserved r00000000 w 0x0018 ptp r ptp7 ptp6 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w pwm pwm3 pwm2 pwm1 pwm0 0x0019 ptip r ptip7 ptip6 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w address name bit 7 654321 bit 0 = unimplemented or reserved figure 2-2. quick reference to pim registers (sheet 2 of 3)
chapter 2 port integration module (pim9c32) block description 78 mc9s12q128 freescale semiconductor rev 1.09 0x001a ddrp r ddrp7 ddrp6 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w 0x001b rdrp r rdrp7 rdrp6 rdrp5 rdrp4 rdrp3 rdrp2 rdrp1 rdrp0 w 0x001c perp r perp7 perp6 perp5 perp4 perp3 perp2 perp1 perp0 w 0x001d ppsp r ppsp7 ppsp6 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w 0x001e piep r piep7 piep6 piep5 piep4 piep3 piep2 piep1 piep0 w 0x001f pifp r pifp7 pifp6 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w 0x0020 0x0027 reserved r00000000 w 0x0028 ptj r ptj7 ptj6 000000 w 0x0029 ptij r ptij7 ptij6 000000 w 0x002a ddrj r ddrj7 ddrj6 000000 w 0x002b rdrj r rdrj7 rdrj6 000000 w 0x002c perj r perj7 perj6 000000 w 0x002d ppsj r ppsj7 ppsj6 000000 w 0x002e piej r piej7 piej6 000000 w 0x002f pifj r pifj7 pifj6 000000 w 0x0030 ptad r ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 w 0x0031 ptiad r ptiad7 ptiad6 ptiad5 ptiad4 ptiad3 ptiad2 ptiad1 ptiad0 w 0x0032 ddrad r ddrad7 ddrad6 ddrad5 ddrad4 ddrad3 ddrad2 ddrad1 ddrad0 w 0x0033 rdrad r rdrad7 rdrad6 rdrad5 rdrad4 rdrad3 rdrad2 rdrad1 rdrad0 w 0x0034 perad r perad7 perad6 perad5 perad4 perad3 perad2 perad1 perad0 w 0x0035 ppsad r ppsad7 ppsad6 ppsad5 ppsad4 ppsad3 ppsad2 ppsad1 ppsad0 w 0x0036 0x003f reserved r00000000 w address name bit 7 654321 bit 0 = unimplemented or reserved figure 2-2. quick reference to pim registers (sheet 3 of 3)
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 79 rev 1.09 2.3.2 register descriptions table 2-2 summarizes the effect on the various configuration bits ?data direction (ddr), input/output level (i/o), reduced drive (rdr), pull enable (pe), pull select (ps), and interrupt enable (ie) for the ports. the configuration bit ps is used for two purposes: 1. con?ure the sensitive interrupt edge (rising or falling), if interrupt is enabled. 2. select either a pull-up or pull-down device if pe is active. note all bits of all registers in this module are completely synchronous to internal clocks during a register read. table 2-2. pin con?uration summary ddr io rdr pe ps ie (1) 1. applicable only on ports p and j. function pull device interrupt 0 x x 0 x 0 input disabled disabled 0 x x 1 0 0 input pull up disabled 0 x x 1 1 0 input pull down disabled 0 x x 0 0 1 input disabled falling edge 0 x x 0 1 1 input disabled rising edge 0 x x 1 0 1 input pull up falling edge 0 x x 1 1 1 input pull down rising edge 1 0 0 x x 0 output, full drive to 0 disabled disabled 1 1 0 x x 0 output, full drive to 1 disabled disabled 1 0 1 x x 0 output, reduced drive to 0 disabled disabled 1 1 1 x x 0 output, reduced drive to 1 disabled disabled 1 0 0 x 0 1 output, full drive to 0 disabled falling edge 1 1 0 x 1 1 output, full drive to 1 disabled rising edge 1 0 1 x 0 1 output, reduced drive to 0 disabled falling edge 1 1 1 x 1 1 output, reduced drive to 1 disabled rising edge
chapter 2 port integration module (pim9c32) block description 80 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.1 port t registers 2.3.2.1.1 port t i/o register (ptt) read: anytime. write: anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. if a tim-channel is de?ed as output, the related port t is assigned to ioc function. in addition to the possible timer functionality of port t pins pwm channels can be routed to port t. for this the module routing register (modrr) needs to be con?ured. module base + 0x0000 76543210 r ptt7 ptt6 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w tim ioc7 ioc6 ioc5 ioc4 ioc3 ioc2 pwm pwm3 pwm2 pwm1 pwm0 reset 0 0 0 00000 = unimplemented or reserved figure 2-3. port t i/o register (ptt) table 2-3. port t[4:0] pin functionality con?urations (1) 1. all ?lds in the that are not shaded are standard use cases. modrr[x] pwme[x] timen[x] (2) 2. timen[x] means that the timer is enabled (tscr1[7]), the related channel is con?ured for output compare function (tios[x] or special output on a timer over?w event con?urable in ttov[x]) and the timer output is routed to the port pin (tctl1/tctl2). port t[x] output 0 0 0 general purpose i/o 0 0 1 timer 0 1 0 general purpose i/o 0 1 1 timer 1 0 0 general purpose i/o 1 0 1 timer 1 1 0 pwm 1 1 1 pwm
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 81 rev 1.09 2.3.2.1.2 port t input register (ptit) read: anytime. write: never, writes to this register have no effect. 2.3.2.1.3 port t data direction register (ddrt) read: anytime. write: anytime. module base + 0x0001 76543210 r ptit7 ptit6 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w reset = unimplemented or reserved figure 2-4. port t input register (ptit) table 2-4. ptit field descriptions field description 7? ptit[7:0] port t input register ?this register always reads back the status of the associated pins. this can also be used to detect overload or short circuit conditions on output pins. module base + 0x0002 76543210 r ddrt7 ddrt6 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w reset 0 0 0 00000 figure 2-5. port t data direction register (ddrt) table 2-5. ddrt field descriptions field description 7? ddrt[7:0] data direction port t ?this register con?ures each port t pin as either input or output. the standard tim / pwm modules forces the i/o state to be an output for each standard tim / pwm module port associated with an enabled output compare. in these cases the data direction bits will not change. the ddrt bits revert to controlling the i/o direction of a pin when the associated timer output compare is disabled. the timer input capture always monitors the state of the pin. 0 associated pin is con?ured as input. 1 associated pin is con?ured as output. note: due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptt or ptit registers, when changing the ddrt register.
chapter 2 port integration module (pim9c32) block description 82 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.1.4 port t reduced drive register (rdrt) read: anytime. write: anytime. 2.3.2.1.5 port t pull device enable register (pert) read: anytime. write: anytime. module base + 0x0003 76543210 r rdrt7 rdrt6 rdrt5 rdrt4 rdrt3 rdrt2 rdrt1 rdrt0 w reset 0 0 0 00000 figure 2-6. port t reduced drive register (rdrt) table 2-6. rdrt field descriptions field description 7? rdrt[7:0] reduced drive port t ?this register con?ures the drive strength of each port t output pin as either full or reduced. if the port is used as input this bit is ignored. 0 full drive strength at output. 1 associated pin drives at about 1/3 of the full drive strength. module base + 0x0004 76543210 r pert7 pert6 pert5 pert4 pert3 pert2 pert1 pert0 w reset 0 0 0 00000 figure 2-7. port t pull device enable register (pert) table 2-7. pert field descriptions field description 7? pert[7:0] pull device enable ?this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input. this bit has no effect if the port is used as output. out of reset no pull device is enabled. 0 pull-up or pull-down device is disabled. 1 either a pull-up or pull-down device is enabled.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 83 rev 1.09 2.3.2.1.6 port t polarity select register (pttst) read: anytime. write: anytime. 2.3.2.1.7 port t module routing register (modrr) read: anytime. write: anytime. note modrr[4] must be kept clear on devices featuring a 4 channel pwm. module base + 0x0005 76543210 r ppst7 ppst6 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w reset 0 0 0 00000 figure 2-8. port t polarity select register (ppst) table 2-8. ppst field descriptions field description 7? ppst[7:0] pull select port t ?this register selects whether a pull-down or a pull-up device is connected to the pin. 0 a pull-up device is connected to the associated port t pin, if enabled by the associated bit in register pert and if the port is used as input. 1 a pull-down device is connected to the associated port t pin, if enabled by the associated bit in register pert and if the port is used as input. module base + 0x0007 76543210 r000 modrr4 modrr3 modrr2 modrr1 modrr0 w reset 00000 = unimplemented or reserved figure 2-9. port t module routing register (modrr) table 2-9. modrr field descriptions field description 4? modrr[4:0] module routing register port t ?this register selects the module connected to port t. 0 associated pin is connected to tim module 1 associated pin is connected to pwm module
chapter 2 port integration module (pim9c32) block description 84 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.2 port s registers 2.3.2.2.1 port s i/o register (pts) read: anytime. write: anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. the sci port associated with transmit pin 1 is configured as output if the transmitter is enabled and the sci pin associated with receive pin 0 is configured as input if the receiver is enabled. please refer to sci block user guide for details . 2.3.2.2.2 port s input register (ptis) read: anytime. write: never, writes to this register have no effect. module base + 0x0008 76543210 r0000 pts3 pts2 pts1 pts0 w scitxdrxd reset 0 0 0 00000 = unimplemented or reserved figure 2-10. port s i/o register (pts) module base + 0x0009 76543210 r 0 0 0 0 ptis3 ptis2 ptis1 ptis0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-11. port s input register (ptis) table 2-10. ptis field descriptions field description 3? ptis[3:0] port s input register ?this register always reads back the status of the associated pins. this also can be used to detect overload or short circuit conditions on output pins.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 85 rev 1.09 2.3.2.2.3 port s data direction register (ddrs) read: anytime. write: anytime. module base + 0x000a 76543210 r0000 ddrs3 ddrs2 ddrs1 ddrs0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-12. port s data direction register (ddrs) table 2-11. ddrs field descriptions field description 3? ddrs[3:0] direction register port s ?this register con?ures each port s pin as either input or output. if the associated sci transmit or receive channel is enabled this register has no effect on the pins. the pin is forced to be an output if the sci transmit channel is enabled, it is forced to be an input if the sci receive channel is enabled. the ddrs bits revert to controlling the i/o direction of a pin when the associated channel is disabled. 0 associated pin is con?ured as input. 1 associated pin is con?ured as output. note: due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on pts or ptis registers, when changing the ddrs register.
chapter 2 port integration module (pim9c32) block description 86 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.2.4 port s reduced drive register (rdrs) read: anytime. write: anytime. 2.3.2.2.5 port s pull device enable register (pers) read: anytime. write: anytime. module base + 0x000b 76543210 r0000 rdrs3 rdrs2 rdrs1 rdrs0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-13. port s reduced drive register (rdrs) table 2-12. rdrs field descriptions field description 3? rdrs[3:0] reduced drive port s ?this register con?ures the drive strength of each port s output pin as either full or reduced. if the port is used as input this bit is ignored. 0 full drive strength at output. 1 associated pin drives at about 1/3 of the full drive strength. module base + 0x000c 76543210 r0000 pers3 pers2 pers1 pers0 w reset 0 0 0 01111 = unimplemented or reserved figure 2-14. port s pull device enable register (pers) table 2-13. pers field descriptions field description 3? pers[3:0] reduced drive port s this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input or as output in wired-or (open drain) mode. this bit has no effect if the port is used as push-pull output. out of reset a pull-up device is enabled. 0 pull-up or pull-down device is disabled. 1 either a pull-up or pull-down device is enabled.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 87 rev 1.09 2.3.2.2.6 port s polarity select register (ppss) read: anytime. write: anytime. 2.3.2.2.7 port s wired-or mode register (woms) read: anytime. write: anytime. module base + 0x000d 76543210 r0000 ppss3 ppss2 ppss1 ppss0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-15. port s polarity select register (ppss) table 2-14. ppss field descriptions field description 3? ppss[3:0] pull select port s ?this register selects whether a pull-down or a pull-up device is connected to the pin. 0 a pull-up device is connected to the associated port s pin, if enabled by the associated bit in register pers and if the port is used as input or as wired-or output. 1 a pull-down device is connected to the associated port s pin, if enabled by the associated bit in register pers and if the port is used as input. module base + 0x000e 76543210 r0000 woms3 woms2 woms1 woms0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-16. port s wired-or mode register (woms) table 2-15. woms field descriptions field description 3? woms[3:0] wired-or mode port s ?this register con?ures the output pins as wired-or. if enabled the output is driven active low only (open-drain). a logic level of ??is not driven. this bit has no in?ence on pins used as inputs. 0 output buffers operate as push-pull outputs. 1 output buffers operate as open-drain outputs.
chapter 2 port integration module (pim9c32) block description 88 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.3 port m registers 2.3.2.3.1 port m i/o register (ptm) read: anytime. write: anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. the spi pin configurations (pm[5:2]) is determined by several status bits in the spi module. please refer to the spi block user guide for details . 2.3.2.3.2 port m input register (ptim) read: anytime. write: never, writes to this register have no effect. module base + 0x0010 76543210 r0 0 ptm5 ptm4 ptm3 ptm2 ptm1 ptm0 w mscan/ spi sck mosi ss miso txcan rxcan reset 0 0 0 00000 = unimplemented or reserved figure 2-17. port m i/o register (ptm) module base + 0x0011 76543210 r 0 0 ptim5 ptim4 ptim3 ptim2 ptim1 ptim0 w reset = unimplemented or reserved figure 2-18. port m input register (ptim) table 2-16. ptim field descriptions field description 5? ptim[5:0] port m input register ?this register always reads back the status of the associated pins. this also can be used to detect overload or short circuit conditions on output pins.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 89 rev 1.09 2.3.2.3.3 port m data direction register (ddrm) read: anytime. write: anytime. module base + 0x0012 76543210 r0 0 ddrm5 ddrm4 ddrm3 ddrm2 ddrm1 ddrm0 w reset 0 00000 = unimplemented or reserved figure 2-19. port m data direction register (ddrm) table 2-17. ddrm field descriptions field description 5? ddrm[5:0] data direction port m ?this register con?ures each port s pin as either input or output if spi or mscan is enabled, the spi and mscan modules determines the pin directions. please refer to the spi and mscan block user guides for details. if the associated sci or mscan transmit or receive channels are enabled, this register has no effect on the pins. the pins are forced to be outputs if the sci or mscan transmit channels are enabled, they are forced to be inputs if the sci or mscan receive channels are enabled. the ddrs bits revert to controlling the i/o direction of a pin when the associated channel is disabled. 0 associated pin is con?ured as input. 1 associated pin is con?ured as output. note: due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptm or ptim registers, when changing the ddrm register.
chapter 2 port integration module (pim9c32) block description 90 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.3.4 port m reduced drive register (rdrm) read: anytime. write: anytime. 2.3.2.3.5 port m pull device enable register (perm) read: anytime. write: anytime. module base + 0x0013 76543210 r0 0 rdrm5 rdrm4 rdrm3 rdrm2 rdrm1 rdrm0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-20. port m reduced drive register (rdrm) table 2-18. rdrm field descriptions field description 5? rdrm[5:0] reduced drive port m ?this register con?ures the drive strength of each port m output pin as either full or reduced. if the port is used as input this bit is ignored. 0 full drive strength at output. 1 associated pin drives at about 1/3 of the full drive strength. module base + 0x0014 76543210 r0 0 perm5 perm4 perm3 perm2 perm1 perm0 w reset 0 0 1 11111 = unimplemented or reserved figure 2-21. port m pull device enable register (perm) table 2-19. perm field descriptions field description 5? perm[5:0] pull device enable port m ?this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input or as output in wired-or (open drain) mode. this bit has no effect if the port is used as push-pull output. out of reset a pull-up device is enabled. 0 pull-up or pull-down device is disabled. 1 either a pull-up or pull-down device is enabled.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 91 rev 1.09 2.3.2.3.6 port m polarity select register (ppsm) read: anytime. write: anytime. 2.3.2.3.7 port m wired-or mode register (womm) read: anytime. write: anytime. module base + 0x0015 76543210 r0 0 ppsm5 ppsm4 ppsm3 ppsm2 ppsm1 ppsm0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-22. port m polarity select register (ppsm) table 2-20. ppsm field descriptions field description 5? ppsm[5:0] polarity select port m ?this register selects whether a pull-down or a pull-up device is connected to the pin. 0 a pull-up device is connected to the associated port m pin, if enabled by the associated bit in register perm and if the port is used as input or as wired-or output. 1 a pull-down device is connected to the associated port m pin, if enabled by the associated bit in register perm and if the port is used as input. module base + 0x0016 76543210 r0 0 womm5 womm4 womm3 womm2 womm1 womm0 w reset 0 0 0 00000 = unimplemented or reserved figure 2-23. port m wired-or mode register (womm) table 2-21. womm field descriptions field description 5? womm[5:0] wired-or mode port m ?this register con?ures the output pins as wired-or. if enabled the output is driven active low only (open-drain). a logic level of ??is not driven. this bit has no in?ence on pins used as inputs. 0 output buffers operate as push-pull outputs. 1 output buffers operate as open-drain outputs.
chapter 2 port integration module (pim9c32) block description 92 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.4 port p registers 2.3.2.4.1 port p i/o register (ptp) read: anytime. write: anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. 2.3.2.4.2 port p input register (ptip) read: anytime. write: never, writes to this register have no effect. this register always reads back the status of the associated pins. this can be also used to detect overload or short circuit conditions on output pins. module base + 0x0018 76543210 r ptp7 ptp6 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w pwm pwm3 pwm2 pwm1 pwm0 reset 0 0 0 00000 figure 2-24. port p i/o register (ptp) module base + 0x0019 76543210 r ptip7 ptip6 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w reset = unimplemented or reserved figure 2-25. port p input register (ptip)
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 93 rev 1.09 2.3.2.4.3 port p data direction register (ddrp) read: anytime. write: anytime. 2.3.2.4.4 port p reduced drive register (rdrp) read: anytime. write: anytime. module base + 0x001a 76543210 r ddrp7 ddrp6 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w reset 0 0 0 00000 figure 2-26. port p data direction register (ddrp) table 2-22. ddrp field descriptions field description 7? ddrp[7:0] data direction port p ?this register con?ures each port p pin as either input or output. 0 associated pin is con?ured as input. 1 associated pin is con?ured as output. note: due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptp or ptip registers, when changing the ddrp register. module base + 0x001b 76543210 r rdrp7 rdrp6 rdrp5 rdrp4 rdrp3 rdrp2 rdrp1 rdrp0 w reset 0 0 0 00000 figure 2-27. port p reduced drive register (rdrp) table 2-23. rdrp field descriptions field description 7? rdrp[7:0] reduced drive port p ?this register con?ures the drive strength of each port p output pin as either full or reduced. if the port is used as input this bit is ignored. 0 full drive strength at output. 1 associated pin drives at about 1/3 of the full drive strength.
chapter 2 port integration module (pim9c32) block description 94 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.4.5 port p pull device enable register (perp) read: anytime. write: anytime. 2.3.2.4.6 port p polarity select register (ppsp) read: anytime. write: anytime. module base + 0x001c 76543210 r perp7 perp6 perp5 perp4 perp3 perp2 perp1 perp0 w reset 0 0 0 00000 figure 2-28. port p pull device enable register (perp) table 2-24. perp field descriptions field description 7? perp[7:0] pull device enable port p this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input. this bit has no effect if the port is used as output. out of reset no pull device is enabled. 0 pull-up or pull-down device is disabled. 1 either a pull-up or pull-down device is enabled. module base + 0x001d 76543210 r ppsp7 ppsp6 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w reset 0 0 0 00000 figure 2-29. port p polarity select register (ppsp) table 2-25. ppsp field descriptions field description 7? ppsp[7:0] pull select port p ?this register serves a dual purpose by selecting the polarity of the active interrupt edge as well as selecting a pull-up or pull-down device if enabled. 0 falling edge on the associated port p pin sets the associated ?g bit in the pifp register.a pull-up device is connected to the associated port p pin, if enabled by the associated bit in register perp and if the port is used as input. 1 rising edge on the associated port p pin sets the associated ?g bit in the pifp register.a pull-down device is connected to the associated port p pin, if enabled by the associated bit in register perp and if the port is used as input.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 95 rev 1.09 2.3.2.4.7 port p interrupt enable register (piep) read: anytime. write: anytime. 2.3.2.4.8 port p interrupt flag register (pifp) read: anytime. write: anytime. module base + 0x001e 76543210 r piep7 piep6 piep5 piep4 piep3 piep2 piep1 piep0 w reset 0 0 0 00000 figure 2-30. port p interrupt enable register (piep) table 2-26. piep field descriptions field description 7? piep[7:0] pull select port p ?this register disables or enables on a per pin basis the edge sensitive external interrupt associated with port p. 0 interrupt is disabled (interrupt ?g masked). 1 interrupt is enabled. module base + 0x001f 76543210 r pifp7 pifp6 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w reset 0 0 0 00000 figure 2-31. port p interrupt flag register (pifp) table 2-27. pifp field descriptions field description 7? pifp[7:0] interrupt flags port p each ?g is set by an active edge on the associated input pin. this could be a rising or a falling edge based on the state of the ppsp register. to clear this ?g, write a ??to the corresponding bit in the pifp register. writing a ??has no effect. 0 no active edge pending. writing a ??has no effect. 1 active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set). writing a ??clears the associated ?g.
chapter 2 port integration module (pim9c32) block description 96 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.5 port j registers 2.3.2.5.1 port j i/o register (ptj) read: anytime. write: anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. 2.3.2.5.2 port j input register (ptij) read: anytime. write: never, writes to this register have no effect. this register always reads back the status of the associated pins. this can be used to detect overload or short circuit conditions on output pins. module base + 0x0028 76543210 r ptj7 ptj6 000000 w reset 0 0 = unimplemented or reserved figure 2-32. port j i/o register (ptj) module base + 0x0029 76543210 r ptij7 ptij6 0 00000 w reset 0 0 = unimplemented or reserved figure 2-33. port j input register (ptij)
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 97 rev 1.09 2.3.2.5.3 port j data direction register (ddrj) read: anytime. write: anytime. 2.3.2.5.4 port j reduced drive register (rdrj) read: anytime. write: anytime. module base + 0x002a 76543210 r ddrj7 ddrj6 000000 w reset 0 0 = unimplemented or reserved figure 2-34. port j data direction register (ddrj) table 2-28. ddrj field descriptions field description 7? ddrj[7:6] data direction port j ?this register con?ures port pins j[7:6] as either input or output. ddrj[7:6] ?data direction port j 0 associated pin is con?ured as input. 1 associated pin is con?ured as output. note: due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptj or ptij registers, when changing the ddrj register. module base + 0x002b 76543210 r rdrj7 rdrj6 000000 w reset 0 0 = unimplemented or reserved figure 2-35. port j reduced drive register (rdrj) table 2-29. rdrj field descriptions field description 7? rdrj[7:6] reduced drive port j ?this register con?ures the drive strength of each port j output pin as either full or reduced. if the port is used as input this bit is ignored. 0 full drive strength at output. 1 associated pin drives at about 1/3 of the full drive strength.
chapter 2 port integration module (pim9c32) block description 98 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.5.5 port j pull device enable register (perj) read: anytime. write: anytime. 2.3.2.5.6 port j polarity select register (ppsj) read: anytime. write: anytime. module base + 0x002c 76543210 r perj7 perj6 000000 w reset 0 0 = unimplemented or reserved figure 2-36. port j pull device enable register (perj) table 2-30. perj field descriptions field description 7? perj[7:6] reduced drive port j this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input or as wired-or output. this bit has no effect if the port is used as push-pull output. 0 pull-up or pull-down device is disabled. 1 either a pull-up or pull-down device is enabled. module base + 0x002d 76543210 r ppsj7 ppsj6 000000 w reset 0 0 = unimplemented or reserved figure 2-37. port j polarity select register (ppsj) table 2-31. ppsj field descriptions field description 7? ppsj[7:6] reduced drive port j this register serves a dual purpose by selecting the polarity of the active interrupt edge as well as selecting a pull-up or pull-down device if enabled. 0 falling edge on the associated port j pin sets the associated ?g bit in the pifj register. a pull-up device is connected to the associated port j pin, if enabled by the associated bit in register perj and if the port is used as general purpose input. 1 rising edge on the associated port j pin sets the associated ?g bit in the pifj register. a pull-down device is connected to the associated port j pin, if enabled by the associated bit in register perj and if the port is used as input.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 99 rev 1.09 2.3.2.5.7 port j interrupt enable register (piej) read: anytime. write: anytime. 2.3.2.5.8 port j interrupt flag register (pifj) read: anytime. write: anytime. module base + 0x002e 76543210 r piej7 piej6 000000 w reset 0 0 = unimplemented or reserved figure 2-38. port j interrupt enable register (piej) table 2-32. piej field descriptions field description 7? piej[7:6] interrupt enable port j ?this register disables or enables on a per pin basis the edge sensitive external interrupt associated with port j. 0 interrupt is disabled (interrupt ?g masked). 1 interrupt is enabled. module base + 0x002f 76543210 r pifj7 pifj6 000000 w reset 0 0 = unimplemented or reserved figure 2-39. port j interrupt flag register (pifj) table 2-33. pifj field descriptions field description 7? pifj[7:6] interrupt flags port j each ?g is set by an active edge on the associated input pin. this could be a rising or a falling edge based on the state of the ppsj register. to clear this ?g, write ??to the corresponding bit in the pifj register. writing a ??has no effect. 0 no active edge pending. writing a ??has no effect. 1 active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set). writing a ??clears the associated ?g.
chapter 2 port integration module (pim9c32) block description 100 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.6 port ad registers 2.3.2.6.1 port ad i/o register (ptad) read: anytime. write: anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. 2.3.2.6.2 port ad input register (ptiad) read: anytime. write: never, writes to this register have no effect. this register always reads back the status of the associated pins. this can be used to detect overload or short circuit conditions on output pins. module base + 0x0030 76543210 r ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 w reset 0 0 0 00000 figure 2-40. port ad i/o register (ptad) module base + 0x0031 76543210 r ptiad7 ptiad6 ptiad5 ptiad4 ptiad3 ptiad2 ptiad1 ptiad0 w reset = unimplemented or reserved figure 2-41. port ad input register (ptiad)
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 101 rev 1.09 2.3.2.6.3 port ad data direction register (ddrad) read: anytime. write: anytime. 2.3.2.6.4 port ad reduced drive register (rdrad) read: anytime. write: anytime. module base + 0x0032 76543210 r ddrad7 ddrad6 ddrad5 ddrad4 ddrad3 ddrad2 ddrad1 ddrad0 w reset 0 0 0 00000 figure 2-42. port ad data direction register (ddrad) table 2-34. ddrad field descriptions field description 7? ddrad[7:0] data direction port ad ?this register con?ures port pins ad[7:0] as either input or output. 0 associated pin is con?ured as input. 1 associated pin is con?ured as output. note: due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptad or ptiad registers, when changing the ddrad register. module base + 0x0033 76543210 r rdrad7 rdrad6 rdrad5 rdrad4 rdrad3 rdrad2 rdrad1 rdrad0 w reset 0 0 0 00000 figure 2-43. port ad reduced drive register (rdrad) table 2-35. rdrad field descriptions field description 7? rdrad[7:0] reduced drive port ad ?this register con?ures the drive strength of each port ad output pin as either full or reduced. if the port is used as input this bit is ignored. 0 full drive strength at output. 1 associated pin drives at about 1/3 of the full drive strength.
chapter 2 port integration module (pim9c32) block description 102 mc9s12q128 freescale semiconductor rev 1.09 2.3.2.6.5 port ad pull device enable register (perad) read: anytime. write: anytime. 2.3.2.6.6 port ad polarity select register (ppsad) read: anytime. write: anytime. module base + 0x0034 76543210 r perad7 perad6 perad5 perad4 perad3 perad2 perad1 perad0 w reset 0 0 0 00000 figure 2-44. port ad pull device enable register (perad) table 2-36. perad field descriptions field description 7? perad[7:0] pull device enable port ad this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input. this bit has no effect if the port is used as output. out of reset no pull device is enabled. it is not possible to enable pull devices when a associated atd channel is enabled simultaneously. 0 pull-up or pull-down device is disabled. 1 either a pull-up or pull-down device is enabled. module base + 0x0035 76543210 r ppsad7 ppsad6 ppsad5 ppsad4 ppsad3 ppsad2 ppsad1 ppsad0 w reset 0 0 0 00000 figure 2-45. port ad polarity select register (ppsad) table 2-37. ppsad field descriptions field description 7? ppsad[7:0] pull select port ad ?this register selects whether a pull-down or a pull-up device is connected to the pin. 0 a pull-up device is connected to the associated port ad pin, if enabled by the associated bit in register perad and if the port is used as input. 1 a pull-down device is connected to the associated port ad pin, if enabled by the associated bit in register perad and if the port is used as input.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 103 rev 1.09 2.4 functional description each pin can act as general purpose i/o. in addition the pin can act as an output from a peripheral module or an input to a peripheral module. a set of configuration registers is common to all ports. all registers can be written at any time, however a specific configuration might not become active. example: selecting a pull-up resistor. this resistor does not become active while the port is used as a push- pull output. 2.4.1 registers 2.4.1.1 i/o register this register holds the value driven out to the pin if the port is used as a general purpose i/o. writing to this register has only an effect on the pin if the port is used as general purpose output. when reading this address, the value of the pins are returned if the data direction register bits are set to 0. if the data direction register bits are set to 1, the contents of the i/o register is returned. this is independent of any other configuration ( figure 2-46 ). figure 2-46. illustration of i/o pin functionality 2.4.1.2 input register this is a read-only register and always returns the value of the pin ( figure 2-46 ). 2.4.1.3 data direction register this register defines whether the pin is used as an input or an output. if a peripheral module controls the pin the contents of the data direction register is ignored ( figure 2-46 ). pt ddr output enable module enable 1 0 1 1 0 0 pa d pti data out module
chapter 2 port integration module (pim9c32) block description 104 mc9s12q128 freescale semiconductor rev 1.09 2.4.1.4 reduced drive register if the port is used as an output the register allows the configuration of the drive strength. 2.4.1.5 pull device enable register this register turns on a pull-up or pull-down device. it becomes only active if the pin is used as an input or as a wired-or output. 2.4.1.6 polarity select register this register selects either a pull-up or pull-down device if enabled. it becomes only active if the pin is used as an input. a pull-up device can be activated if the pin is used as a wired-or output. 2.4.2 port descriptions 2.4.2.1 port t this port is associated with the standard capture timer. pwm output channels can be rerouted from port p to port pins t. in all modes, port t pins can be used for either general-purpose i/o, standard capture timer i/o or as pwm channels module, if so configured by modrr. during reset, port t pins are configured as high-impedance inputs. 2.4.2.2 port s this port is associated with the serial sci module. port s pins ps[3:0] can be used either for general- purpose i/o, or with the sci subsystem. during reset, port s pins are configured as inputs with pull-up. 2.4.2.3 port m this port is associated with the mscan and spi module. port m pins pm[5:0] can be used either for general-purpose i/o, with the mscan or spi subsystems. during reset, port m pins are configured as inputs with pull-up. 2.4.2.4 port ad this port is associated with the atd module. port ad pins can be used either for general-purpose i/o, or for the atd subsystem. there are 2 data port registers associated with the port ad: ptad[7:0], located in the pim and portad[7:0] located in the atd. to use ptad[n] as a standard input port, the corresponding ddrd[n] must be cleared. to use ptad[n] as a standard output port, the corresponding ddrd[n] must be set note: to use portad[n], located in the atd as an input port register, ddrd[n] must be cleared and atddien[n] must be set. please refer to atd block guide for details .
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 105 rev 1.09 2.4.2.5 port p the pwm module is connected to port p. port p pins can be used as pwm outputs. further the keypad wake-up function is implemented on pins pp[7:0]. during reset, port p pins are configured as high- impedance inputs. port p offers 8 general purpose i/o pins with edge triggered interrupt capability in wired-or fashion. the interrupt enable as well as the sensitivity to rising or falling edges can be individually configured on per pin basis. all 8 bits/pins share the same interrupt vector. interrupts can be used with the pins configured as inputs or outputs. an interrupt is generated when a bit in the port interrupt flag register and its corresponding port interrupt enable bit are both set. this external interrupt feature is capable to wake up the cpu when it is in stop or wait mode. a digital filter on each pin prevents pulses ( figure 2-48 ) shorter than a specified time from generating an interrupt. the minimum time varies over process conditions, temperature and voltage ( figure 2-47 and table 2-38 ). figure 2-47. interrupt glitch filter on port p and j (pps = 0) figure 2-48. pulse illustration table 2-38. pulse detection criteria pulse st op mode stop (1) mode 1. these values include the spread of the oscillator frequency over temperature, voltage and process. value unit value unit ignored t pign <= 3 bus clocks t pign <= 3.2 s uncertain 3 < t pulse < 4 bus clocks 3.2 < t pulse < 10 s valid t pval >= 4 bus clocks t pval >= 10 s glitch, ?tered out, no interrupt ?g set valid pulse, interrupt ?g set t pign t pval t pulse
chapter 2 port integration module (pim9c32) block description 106 mc9s12q128 freescale semiconductor rev 1.09 a valid edge on input is detected if 4 consecutive samples of a passive level are followed by 4 consecutive samples of an active level directly or indirectly. the filters are continuously clocked by the bus clock in run and wait mode. in stop mode the clock is generated by a single rc oscillator in the port integration module. to maximize current saving the rc oscillator runs only if the following condition is true on any pin: sample count <= 4 and port interrupt enabled (pie=1) and port interrupt flag not set (pif=0). 2.4.2.6 port j in all modes, port j pins pj[7:6] can be used for general purpose i/o or interrupt driven general purpose i/o?. during reset, port j pins are configured as inputs. port j offers 2 i/o ports with the same interrupt features as on port p. 2.4.3 port a, b, e and bkgd pin all port and pin logic is located in the core module. please refer to s12_mebi block user guide for details. 2.4.4 external pin descriptions all ports start up as general purpose inputs on reset. 2.4.5 low power options 2.4.5.1 run mode no low power options exist for this module in run mode. 2.4.5.2 wait mode no low power options exist for this module in wait mode. 2.4.5.3 stop mode all clocks are stopped. there are asynchronous paths to generate interrupts from stop on port p and j. 2.5 initialization information the reset values of all registers are given in section 2.3.2, ?egister descriptions . 2.5.1 reset initialization all registers including the data registers get set/reset asynchronously. table 2-39 summarizes the port properties after reset initialization.
chapter 2 port integration module (pim9c32) block description freescale semiconductor mc9s12q128 107 rev 1.09 2.6 interrupts port p and j generate a separate edge sensitive interrupt if enabled. 2.6.1 interrupt sources note vector addresses and their relative interrupt priority are determined at the mcu level. 2.6.2 recovery from stop the pim can generate wake-up interrupts from stop on port p and j. for other sources of external interrupts please refer to the respective block user guide. 2.7 application information it is not recommended to write portx and ddrx in a word access. when changing the register pins from inputs to outputs, the data may have extra transitions during the write access. initialize the port data register before enabling the outputs. power consumption will increase the more the voltages on general purpose input pins deviate from the supply voltages towards mid-range because the digital input buffers operate in the linear region. table 2-39. port reset state summary port reset states data direction pull mode reduced drive wired-or mode interrupt t input hi-z disabled n/a n/a s input pull up disabled disabled n/a m input pull up disabled disabled n/a p input hi-z disabled n/a disabled j input hi-z disabled n/a disabled a refer to mebi block guide for details. b e bkgd pin refer to bdm block guide for details. table 2-40. port integration module interrupt sources interrupt source interrupt flag local enable global (ccr) mask port p pifp[7:0] piep[7:0] i bit port j pifj[7:6] piej[7:6] i bit
chapter 2 port integration module (pim9c32) block description 108 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 109 rev 1.09 chapter 3 module mapping control (mmcv4) block description 3.1 introduction this section describes the functionality of the module mapping control (mmc) sub-block of the s12 core platform. the block diagram of the mmc is shown in figure 3-1 . figure 3-1. mmc block diagram the mmc is the sub-module which controls memory map assignment and selection of internal resources and external space. internal buses between the core and memories and between the core and peripherals is controlled in this module. the memory expansion is generated in this module. mmc mode information registers cpu write data bus cpu address bus cpu control stop, wait address decode cpu read data bus ebi alternate address bus ebi alternate write data bus ebi alternate read data bus security clocks, reset read & write enables alternate address bus (bdm) alternate write data bus (bdm) alternate read data bus (bdm) core select (s) port k interface memory space select(s) peripheral select bus control secure bdm_unsecure mmc_secure internal memory expansion
chapter 3 module mapping control (mmcv4) block description 110 mc9s12q128 freescale semiconductor rev 1.09 3.1.1 features registers for mapping of address space for on-chip ram, eeprom, and flash (or rom) memory blocks and associated registers memory mapping control and selection based upon address decode and system operating mode core address bus control core data bus control and multiplexing core security state decoding emulation chip select signal generation ( ecs) external chip select signal generation ( xcs) internal memory expansion external stretch and rom mapping control functions via the misc register reserved registers for test purposes con?urable system memory options de?ed at integration of core into the system-on-a-chip (soc). 3.1.2 modes of operation some of the registers operate differently depending on the mode of operation (i.e., normal expanded wide, special single chip, etc.). this is best understood from the register descriptions. 3.2 external signal description all interfacing with the mmc sub-block is done within the core, it has no external signals. 3.3 memory map and register de?ition a summary of the registers associated with the mmc sub-block is shown in figure 3-2 . detailed descriptions of the registers and bits are given in the subsections that follow. 3.3.1 module memory map table 3-1. mmc memory map address offset register access 0x0010 initialization of internal ram position register (initrm) r/w 0x0011 initialization of internal registers position register (initrg) r/w 0x0012 initialization of internal eeprom position register (initee) r/w 0x0013 miscellaneous system control register (misc) r/w 0x0014 reserved . . . .
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 111 rev 1.09 0x0017 reserved . . . . 0x001c memory size register 0 (memsiz0) r 0x001d memory size register 1 (memsiz1) r . . . . 0x0030 program page index register (ppage) r/w 0x0031 reserved table 3-1. mmc memory map (continued) address offset register access
chapter 3 module mapping control (mmcv4) block description 112 mc9s12q128 freescale semiconductor rev 1.09 3.3.2 register descriptions name bit 7 6 5 4321 bit 0 0x0010 initrm r ram15 ram14 ram13 ram12 ram11 00 ramhal w 0x0011 initrg r0 reg14 reg13 reg12 reg11 000 w 0x0012 initee r ee15 ee14 ee13 ee12 ee11 00 eeon w 0x0013 misc r0000 exstr1 exstr0 romhm romon w 0x0014 mtsto r bit 7 6 5 4321 bit 0 w 0x0017 mtst1 r bit 7 6 5 4321 bit 0 w 0x001c memsiz0 r reg_sw0 0 eep_sw1 eep_sw0 0 ram_sw2 ram_sw1 ram_sw0 w 0x001d memsiz1 r rom_sw1 rom_sw0 0 0 0 0 pag_sw1 pag_sw0 w 0x0030 ppage r0 0 pix5 pix4 pix3 pix2 pix1 pix0 w 0x0031 reserved r00000000 w = unimplemented figure 3-2. mmc register summary
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 113 rev 1.09 3.3.2.1 initialization of internal ram position register (initrm) read: anytime write: once in normal and emulation modes, anytime in special modes note writes to this register take one cycle to go into effect. this register initializes the position of the internal ram within the on-chip system memory map. module base + 0x0010 starting address location affected by initrg register setting. 76543210 r ram15 ram14 ram13 ram12 ram11 00 ramhal w reset 0 0 0 01001 = unimplemented or reserved figure 3-3. initialization of internal ram position register (initrm) table 3-2. initrm field descriptions field description 7:3 ram[15:11] internal ram map position ?these bits determine the upper ?e bits of the base address for the systems internal ram array. 0 ramhal ram high-align ?ramhal speci?s the alignment of the internal ram array. 0 aligns the ram to the lowest address (0x0000) of the mappable space 1 aligns the ram to the higher address (0xffff) of the mappable space
chapter 3 module mapping control (mmcv4) block description 114 mc9s12q128 freescale semiconductor rev 1.09 3.3.2.2 initialization of internal registers position register (initrg) read: anytime write: once in normal and emulation modes and anytime in special modes this register initializes the position of the internal registers within the on-chip system memory map. the registers occupy either a 1k byte or 2k byte space and can be mapped to any 2k byte space within the ?st 32k bytes of the systems address space. module base + 0x0011 starting address location affected by initrg register setting. 76543210 r0 reg14 reg13 reg12 reg11 000 w reset 0 0 0 00000 = unimplemented or reserved figure 3-4. initialization of internal registers position register (initrg) table 3-3. initrg field descriptions field description 6:3 reg[14:11] internal register map position ?these four bits in combination with the leading zero supplied by bit 7 of initrg determine the upper ?e bits of the base address for the systems internal registers (i.e., the minimum base address is 0x0000 and the maximum is 0x7fff).
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 115 rev 1.09 3.3.2.3 initialization of internal eeprom position register (initee) read: anytime write: the eeon bit can be written to any time on all devices. bits e[11:15] are ?rite anytime in all modes on most devices. on some devices, bits e[11:15] are ?rite once in normal and emulation modes and write anytime in special modes? see device overview chapter to determine the actual write access rights. note writes to this register take one cycle to go into effect. this register initializes the position of the internal eeprom within the on-chip system memory map. module base + 0x0012 starting address location affected by initrg register setting. 76543210 r ee15 ee14 ee13 ee12 ee11 00 eeon w reset 1 1. the reset state of this register is controlled at chip integration. please refer to the device overview section to determine the actual reset state of this register. = unimplemented or reserved figure 3-5. initialization of internal eeprom position register (initee) table 3-4. initee field descriptions field description 7:3 ee[15:11] internal eeprom map position these bits determine the upper ?e bits of the base address for the systems internal eeprom array. 0 eeon enable eeprom ?this bit is used to enable the eeprom memory in the memory map. 0 disables the eeprom from the memory map. 1 enables the eeprom in the memory map at the address selected by ee[15:11].
chapter 3 module mapping control (mmcv4) block description 116 mc9s12q128 freescale semiconductor rev 1.09 3.3.2.4 miscellaneous system control register (misc) read: anytime write: as stated in each bit description note writes to this register take one cycle to go into effect. this register initializes miscellaneous control functions. module base + 0x0013 starting address location affected by initrg register setting. 76543210 r0000 exstr1 exstr0 romhm romon w reset: expanded or emulation 0000110 1 reset: peripheral or single chip 00001101 reset: special test 00001100 1. the reset state of this bit is determined at the chip integration level. = unimplemented or reserved figure 3-6. miscellaneous system control register (misc) table 3-5. initee field descriptions field description 3:2 exstr[1:0] external access stretch bits 1 and 0 write: once in normal and emulation modes and anytime in special modes this two-bit ?ld determines the amount of clock stretch on accesses to the external address space as shown in table 3-6 . in single chip and peripheral modes these bits have no meaning or effect. 1 romhm flash eeprom or rom only in second half of memory map write: once in normal and emulation modes and anytime in special modes 0 the ?ed page(s) of flash eeprom or rom in the lower half of the memory map can be accessed. 1 disables direct access to the flash eeprom or rom in the lower half of the memory map. these physical locations of the flash eeprom or rom remain accessible through the program page window. 0 romon romon ?enable flash eeprom or rom write: once in normal and emulation modes and anytime in special modes this bit is used to enable the flash eeprom or rom memory in the memory map. 0 disables the flash eeprom or rom from the memory map. 1 enables the flash eeprom or rom in the memory map.
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 117 rev 1.09 3.3.2.5 reserved test register 0 (mtst0) read: anytime write: no effect ?this register location is used for internal test purposes. 3.3.2.6 reserved test register 1 (mtst1) read: anytime write: no effect ?this register location is used for internal test purposes. table 3-6. external stretch bit de?ition stretch bit exstr1 stretch bit exstr0 number of e clocks stretched 00 0 01 1 10 2 11 3 module base + 0x0014 starting address location affected by initrg register setting. 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 3-7. reserved test register 0 (mtst0) module base + 0x0017 starting address location affected by initrg register setting. 76543210 r00000000 w reset 0 0 0 10000 = unimplemented or reserved figure 3-8. reserved test register 1 (mtst1)
chapter 3 module mapping control (mmcv4) block description 118 mc9s12q128 freescale semiconductor rev 1.09 3.3.2.7 memory size register 0 (memsiz0) read: anytime write: writes have no effect reset: de?ed at chip integration, see device overview section. the memsiz0 register re?cts the state of the register, eeprom and ram memory space con?uration switches at the core boundary which are con?ured at system integration. this register allows read visibility to the state of these switches. module base + 0x001c starting address location affected by initrg register setting. 76543210 r reg_sw0 0 eep_sw1 eep_sw0 0 ram_sw2 ram_sw1 ram_sw0 w reset = unimplemented or reserved figure 3-9. memory size register 0 (memsiz0) table 3-7. memsiz0 field descriptions field description 7 reg_sw0 allocated system register space 0 allocated system register space size is 1k byte 1 allocated system register space size is 2k byte 5:4 eep_sw[1:0] allocated system eeprom memory space ?the allocated system eeprom memory space size is as given in table 3-8 . 2 ram_sw[2:0] allocated system ram memory space ?the allocated system ram memory space size is as given in table 3-9 . table 3-8. allocated eeprom memory space eep_sw1:eep_sw0 allocated eeprom space 00 0k byte 01 2k bytes 10 4k bytes 11 8k bytes table 3-9. allocated ram memory space ram_sw2:ram_sw0 allocated ram space ram mappable region initrm bits used ram reset base address (1) 000 2k bytes 2k bytes ram[15:11] 0x0800 001 4k bytes 4k bytes ram[15:12] 0x0000 010 6k bytes 8k bytes (2) ram[15:13] 0x0800
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 119 rev 1.09 note as stated, the bits in this register provide read visibility to the system physical memory space allocations de?ed at system integration. the actual array size for any given type of memory block may differ from the allocated size. please refer to the device overview chapter for actual sizes. 3.3.2.8 memory size register 1 (memsiz1) read: anytime write: writes have no effect reset: de?ed at chip integration, see device overview section. the memsiz1 register re?cts the state of the flash or rom physical memory space and paging switches at the core boundary which are con?ured at system integration. this register allows read visibility to the state of these switches. 011 8k bytes 8k bytes ram[15:13] 0x0000 100 10k bytes 16k bytes 2 ram[15:14] 0x1800 101 12k bytes 16k bytes 2 ram[15:14] 0x1000 110 14k bytes 16k bytes 2 ram[15:14] 0x0800 111 16k bytes 16k bytes ram[15:14] 0x0000 1. the ram reset base address is based on the reset value of the initrm register, 0x0009. 2. alignment of the allocated ram space within the ram mappable region is dependent on the value of ramhal. module base + 0x001d starting address location affected by initrg register setting. 76543210 r rom_sw1 rom_sw0 0 0 0 0 pag_sw1 pag_sw0 w reset = unimplemented or reserved figure 3-10. memory size register 1 (memsiz1) table 3-9. allocated ram memory space (continued) ram_sw2:ram_sw0 allocated ram space ram mappable region initrm bits used ram reset base address (1)
chapter 3 module mapping control (mmcv4) block description 120 mc9s12q128 freescale semiconductor rev 1.09 note as stated, the bits in this register provide read visibility to the system memory space and on-chip/off-chip partitioning allocations de?ed at system integration. the actual array size for any given type of memory block may differ from the allocated size. please refer to the device overview chapter for actual sizes. table 3-10. memsiz0 field descriptions field description 7:6 rom_sw[1:0] allocated system flash or rom physical memory space ?the allocated system flash or rom physical memory space is as given in table 3-11 . 1:0 pag_sw[1:0] allocated off-chip flash or rom memory space the allocated off-chip flash or rom memory space size is as given in table 3-12 . table 3-11. allocated flash/rom physical memory space rom_sw1:rom_sw0 allocated flash or rom space 00 0k byte 01 16k bytes 10 48k bytes (1) 11 64k bytes (1) notes: 1. the romhm software bit in the misc register determines the accessibility of the flash/rom memory space. please refer to section 3.3.2.8, ?emory size register 1 (memsiz1) , for a detailed functional description of the romhm bit. table 3-12. allocated off-chip memory options pag_sw1:pag_sw0 off-chip space on-chip space 00 876k bytes 128k bytes 01 768k bytes 256k bytes 10 512k bytes 512k bytes 11 0k byte 1m byte
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 121 rev 1.09 3.3.2.9 program page index register (ppage) read: anytime write: determined at chip integration. generally its: ?rite anytime in all modes; on some devices it will be: ?rite only in special modes.?check speci? device documentation to determine which applies. reset: de?ed at chip integration as either 0x00 (paired with write in any mode) or 0x3c (paired with write only in special modes), see device overview chapter. the hcs12 core architecture limits the physical address space available to 64k bytes. the program page index register allows for integrating up to 1m byte of flash or rom into the system by using the six page index bits to page 16k byte blocks into the program page window located from 0x8000 to 0xbfff as de?ed in table 3-14 . call and rtc instructions have special access to read and write this register without using the address bus. note normal writes to this register take one cycle to go into effect. writes to this register using the special access of the call and rtc instructions will be complete before the end of the associated instruction. module base + 0x0030 starting address location affected by initrg register setting. 76543210 r0 0 pix5 pix4 pix3 pix2 pix1 pix0 w reset 1 1. the reset state of this register is controlled at chip integration. please refer to the device overview section to determine the actual reset state of this register. = unimplemented or reserved figure 3-11. program page index register (ppage) table 3-13. memsiz0 field descriptions field description 5:0 pix[5:0] program page index bits 5:0 ?these page index bits are used to select which of the 64 flash or rom array pages is to be accessed in the program page window as shown in table 3-14 .
chapter 3 module mapping control (mmcv4) block description 122 mc9s12q128 freescale semiconductor rev 1.09 3.4 functional description the mmc sub-block performs four basic functions of the core operation: bus control, address decoding and select signal generation, memory expansion, and security decoding for the system. each aspect is described in the following subsections. 3.4.1 bus control the mmc controls the address bus and data buses that interface the core with the rest of the system. this includes the multiplexing of the input data buses to the core onto the main cpu read data bus and control of data ?w from the cpu to the output address and data buses of the core. in addition, the mmc manages all cpu read data bus swapping operations. 3.4.2 address decoding as data ?ws on the core address bus, the mmc decodes the address information, determines whether the internal core register or ?mware space, the peripheral space or a memory register or array space is being addressed and generates the correct select signal. this decoding operation also interprets the mode of operation of the system and the state of the mapping control registers in order to generate the proper select. the mmc also generates two external chip select signals, emulation chip select ( ecs) and external chip select ( xcs). 3.4.2.1 select priority and mode considerations although internal resources such as control registers and on-chip memory have default addresses, each can be relocated by changing the default values in control registers. normally, i/o addresses, control registers, table 3-14. program page index register bits pix5 pix4 pix3 pix2 pix1 pix0 program space selected 000000 16k page 0 000001 16k page 1 000010 16k page 2 000011 16k page 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111100 16k page 60 111101 16k page 61 111110 16k page 62 111111 16k page 63
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 123 rev 1.09 vector spaces, expansion windows, and on-chip memory are mapped so that their address ranges do not overlap. the mmc will make only one select signal active at any given time. this activation is based upon the priority outlined in table 3-15 . if two or more blocks share the same address space, only the select signal for the block with the highest priority will become active. an example of this is if the registers and the ram are mapped to the same space, the registers will have priority over the ram and the portion of ram mapped in this shared space will not be accessible. the expansion windows have the lowest priority. this means that registers, vectors, and on-chip memory are always visible to a program regardless of the values in the page select registers. in expanded modes, all address space not used by internal resources is by default external memory space. the data registers and data direction registers for ports a and b are removed from the on-chip memory map and become external accesses. if the eme bit in the mode register (see mebi block description chapter) is set, the data and data direction registers for port e are also removed from the on-chip memory map and become external accesses. in special peripheral mode, the ?st 16 registers associated with bus expansion are removed from the on- chip memory map (porta, portb, ddra, ddrb, porte, ddre, pear, mode, pucr, rdriv, and the ebi reserved registers). in emulation modes, if the emk bit in the mode register (see mebi block description chapter) is set, the data and data direction registers for port k are removed from the on-chip memory map and become external accesses. 3.4.2.2 emulation chip select signal when the emk bit in the mode register (see mebi block description chapter) is set, port k bit 7 is used as an active-low emulation chip select signal, ecs. this signal is active when the system is in emulation mode, the emk bit is set and the flash or rom space is being addressed subject to the conditions outlined in section 3.4.3.2, ?xtended address (xab19:14) and ecs signal functionality . when the emk bit is clear, this pin is used for general purpose i/o. 3.4.2.3 external chip select signal when the emk bit in the mode register (see mebi block description chapter) is set, port k bit 6 is used as an active-low external chip select signal, xcs. this signal is active only when the ecs signal described above is not active and when the system is addressing the external address space. accesses to table 3-15. select signal priority priority address space highest bdm (internal to core) ?mware or register space ... internal register space ... ram memory block ... eeprom memory block ... on-chip flash or rom lowest remaining external space
chapter 3 module mapping control (mmcv4) block description 124 mc9s12q128 freescale semiconductor rev 1.09 unimplemented locations within the register space or to locations that are removed from the map (i.e., ports a and b in expanded modes) will not cause this signal to become active. when the emk bit is clear, this pin is used for general purpose i/o. 3.4.3 memory expansion the hcs12 core architecture limits the physical address space available to 64k bytes. the program page index register allows for integrating up to 1m byte of flash or rom into the system by using the six page index bits to page 16k byte blocks into the program page window located from 0x8000 to 0xbfff in the physical memory space. the paged memory space can consist of solely on-chip memory or a combination of on-chip and off-chip memory. this partitioning is con?ured at system integration through the use of the paging con?uration switches ( pag_sw1:pag_sw0 ) at the core boundary. the options available to the integrator are as given in table 3-16 (this table matches table 3-12 but is repeated here for easy reference). based upon the system con?uration, the program page window will consider its access to be either internal or external as de?ed in table 3-17 . note the partitioning as de?ed in table 3-17 applies only to the allocated memory space and the actual on-chip memory sizes implemented in the system may differ. please refer to the device overview chapter for actual sizes. table 3-16. allocated off-chip memory options pag_sw1:pag_sw0 off-chip space on-chip space 00 876k bytes 128k bytes 01 768k bytes 256k bytes 10 512k bytes 512k bytes 11 0k byte 1m byte table 3-17. external/internal page window access pag_sw1:pag_sw0 partitioning pix5:0 value page window access 00 876k off-chip, 128k on-chip 0x0000?x0037 external 0x0038?x003f internal 01 768k off-chip, 256k on-chip 0x0000?x002f external 0x0030?x003f internal 10 512k off-chip, 512k on-chip 0x0000?x001f external 0x0020?x003f internal 11 0k off-chip, 1m on-chip n/a external 0x0000?x003f internal
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 125 rev 1.09 the ppage register holds the page select value for the program page window. the value of the ppage register can be manipulated by normal read and write (some devices dont allow writes in some modes) instructions as well as the call and rtc instructions. control registers, vector spaces, and a portion of on-chip memory are located in unpaged portions of the 64k byte physical address space. the stack and i/o addresses should also be in unpaged memory to make them accessible from any page. the starting address of a service routine must be located in unpaged memory because the 16-bit exception vectors cannot point to addresses in paged memory. however, a service routine can call other routines that are in paged memory. the upper 16k byte block of memory space (0xc000?xffff) is unpaged. it is recommended that all reset and interrupt vectors point to locations in this area. 3.4.3.1 call and return from call instructions call and rtc are uninterruptable instructions that automate page switching in the program expansion window. call is similar to a jsr instruction, but the subroutine that is called can be located anywhere in the normal 64k byte address space or on any page of program expansion memory. call calculates and stacks a return address, stacks the current ppage value, and writes a new instruction-supplied value to ppage. the ppage value controls which of the 64 possible pages is visible through the 16k byte expansion window in the 64k byte memory map. execution then begins at the address of the called subroutine. during the execution of a call instruction, the cpu: writes the old ppage value into an internal temporary register and writes the new instruction- supplied ppage value into the ppage register. calculates the address of the next instruction after the call instruction (the return address), and pushes this 16-bit value onto the stack. pushes the old ppage value onto the stack. calculates the effective address of the subroutine, re?ls the queue, and begins execution at the new address on the selected page of the expansion window. this sequence is uninterruptable; there is no need to inhibit interrupts during call execution. a call can be performed from any address in memory to any other address. the ppage value supplied by the instruction is part of the effective address. for all addressing mode variations except indexed-indirect modes, the new page value is provided by an immediate operand in the instruction. in indexed-indirect variations of call, a pointer speci?s memory locations where the new page value and the address of the called subroutine are stored. using indirect addressing for both the new page value and the address within the page allows values calculated at run time rather than immediate values that must be known at the time of assembly. the rtc instruction terminates subroutines invoked by a call instruction. rtc unstacks the ppage value and the return address and re?ls the queue. execution resumes with the next instruction after the call.
chapter 3 module mapping control (mmcv4) block description 126 mc9s12q128 freescale semiconductor rev 1.09 during the execution of an rtc instruction, the cpu: pulls the old ppage value from the stack pulls the 16-bit return address from the stack and loads it into the pc writes the old ppage value into the ppage register re?ls the queue and resumes execution at the return address this sequence is uninterruptable; an rtc can be executed from anywhere in memory, even from a different page of extended memory in the expansion window. the call and rtc instructions behave like jsr and rts, except they use more execution cycles. therefore, routinely substituting call/rtc for jsr/rts is not recommended. jsr and rts can be used to access subroutines that are on the same page in expanded memory. however, a subroutine in expanded memory that can be called from other pages must be terminated with an rtc. and the rtc unstacks a ppage value. so any access to the subroutine, even from the same page, must use a call instruction so that the correct ppage value is in the stack. 3.4.3.2 extended address (xab19:14) and ecs signal functionality if the emk bit in the mode register is set (see mebi block description chapter) the pix5:0 values will be output on xab19:14 respectively (port k bits 5:0) when the system is addressing within the physical program page window address space (0x8000?xbfff) and is in an expanded mode. when addressing anywhere else within the physical address space (outside of the paging space), the xab19:14 signals will be assigned a constant value based upon the physical address space selected. in addition, the active-low emulation chip select signal, ecs, will likewise function based upon the assigned memory allocation. in the cases of 48k byte and 64k byte allocated physical flash/rom space, the operation of the ecs signal will additionally depend upon the state of the romhm bit (see section 3.3.2.4, ?iscellaneous system control register (misc) ? in the misc register. table 3-18 , table 3-19 , table 3-20 , and table 3- 21 summarize the functionality of these signals based upon the allocated memory con?uration. again, this signal information is only available externally when the emk bit is set and the system is in an expanded mode. table 3-18. 0k byte physical flash/rom allocated address space page window access romhm ecs xab19:14 0x0000?x3fff n/a n/a 1 0x3d 0x4000?x7fff n/a n/a 1 0x3e 0x8000?xbfff n/a n/a 0 pix[5:0] 0xc000?xffff n/a n/a 0 0x3f table 3-19. 16k byte physical flash/rom allocated address space page window access romhm ecs xab19:14 0x0000?x3fff n/a n/a 1 0x3d 0x4000?x7fff n/a n/a 1 0x3e 0x8000?xbfff n/a n/a 1 pix[5:0] 0xc000?xffff n/a n/a 0 0x3f
chapter 3 module mapping control (mmcv4) block description freescale semiconductor mc9s12q128 127 rev 1.09 table 3-20. 48k byte physical flash/rom allocated address space page window access romhm ecs xab19:14 0x0000?x3fff n/a n/a 1 0x3d 0x4000?x7fff n/a 0 0 0x3e n/a 1 1 0x8000?xbfff external n/a 1 pix[5:0] internal n/a 0 0xc000?xffff n/a n/a 0 0x3f table 3-21. 64k byte physical flash/rom allocated address space page window access romhm ecs xab19:14 0x0000?x3fff n/a 0 0 0x3d n/a 1 1 0x4000?x7fff n/a 0 0 0x3e n/a 1 1 0x8000?xbfff external n/a 1 pix[5:0] internal n/a 0 0xc000?xffff n/a n/a 0 0x3f
chapter 3 module mapping control (mmcv4) block description 128 mc9s12q128 freescale semiconductor rev 1.09 a graphical example of a memory paging for a system con?ured as 1m byte on-chip flash/rom with 64k allocated physical space is given in figure 3-12 . figure 3-12. memory paging example: 1m byte on-chip flash/rom, 64k allocation these 16k flash/rom pages accessible from 0x0000 to 0x7fff if selected by the romhm bit in the misc register. normal single chip one 16k flash/rom page accessible at a time (selected by ppage = 0 to 63) 0x0000 0x8000 0xff00 0xffff 0x4000 0xc000 59 62 63 60 61 62 63 0123 61 16k flash (unpaged) 16k flash (unpaged) 16k flash (paged) 16k flash (unpaged) vectors
freescale semiconductor mc9s12q128 129 rev 1.09 chapter 4 multiplexed external bus interface (mebiv3) 4.1 introduction this section describes the functionality of the multiplexed external bus interface (mebi) sub-block of the s12 core platform. the functionality of the module is closely coupled with the s12 cpu and the memory map controller (mmc) sub-blocks. figure 4-1 is a block diagram of the mebi. in figure 4-1 , the signals on the right hand side represent pins that are accessible externally. on some chips, these may not all be bonded out. the mebi sub-block of the core serves to provide access and/or visibility to internal core data manipulation operations including timing reference information at the external boundary of the core and/or system. depending upon the system operating mode and the state of bits within the control registers of the mebi, the internal 16-bit read and write data operations will be represented in 8-bit or 16-bit accesses externally. using control information from other blocks within the system, the mebi will determine the appropriate type of data access to be generated. 4.1.1 features the block name includes these distinctive features: external bus controller with four 8-bit ports a,b, e, and k data and data direction registers for ports a, b, e, and k when used as general-purpose i/o control register to enable/disable alternate functions on ports e and k mode control register control register to enable/disable pull resistors on ports a, b, e, and k control register to enable/disable reduced output drive on ports a, b, e, and k control register to con?ure external clock behavior control register to con?ure irq pin operation logic to capture and synchronize external interrupt pin inputs
chapter 4 multiplexed external bus interface (mebiv3) 130 mc9s12q128 freescale semiconductor rev 1.09 figure 4-1. mebi block diagram pe[7:2]/noacc/ pe1/ irq pe0/ xirq bkgd/modc/ t a ghi pk[7:0]/ ecs/ xcs/x[19:14] pa[7:0]/a[15:8]/ d[15:8]/d[7:0] port k port a pb[7:0]/a[7:0]/ d[7:0] port b port e bkgd regs ext bus i/f ctl addr[19:0] data[15:0] (control) internal bus eclk ctl irq ctl addr addr data addr data pipe ctl cpu pipe info irq interrupt xirq interrupt bdm tag info ipipe1/modb/clkto ipipe0/moda/ eclk/ lstrb/ t a glo r/ w tag ctl control signal(s) data signal (unidirectional) data bus (unidirectional) data bus (bidirectional) data signal (bidirectional) mode
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 131 rev 1.09 4.1.2 modes of operation normal expanded wide mode ports a and b are con?ured as a 16-bit multiplexed address and data bus and port e provides bus control and status signals. this mode allows 16-bit external memory and peripheral devices to be interfaced to the system. normal expanded narrow mode ports a and b are con?ured as a 16-bit address bus and port a is multiplexed with 8-bit data. port e provides bus control and status signals. this mode allows 8-bit external memory and peripheral devices to be interfaced to the system. normal single-chip mode there is no external expansion bus in this mode. the processor program is executed from internal memory. ports a, b, k, and most of e are available as general-purpose i/o. special single-chip mode this mode is generally used for debugging single-chip operation, boot-strapping, or security related operations. the active background mode is in control of cpu execution and bdm ?mware is waiting for additional serial commands through the bkgd pin. there is no external expansion bus after reset in this mode. emulation expanded wide mode developers use this mode for emulation systems in which the users target application is normal expanded wide mode. emulation expanded narrow mode developers use this mode for emulation systems in which the users target application is normal expanded narrow mode. special test mode ports a and b are con?ured as a 16-bit multiplexed address and data bus and port e provides bus control and status signals. in special test mode, the write protection of many control bits is lifted so that they can be thoroughly tested without needing to go through reset. special peripheral mode this mode is intended for freescale semiconductor factory testing of the system. the cpu is inactive and an external (tester) bus master drives address, data, and bus control signals. 4.2 external signal description in typical implementations, the mebi sub-block of the core interfaces directly with external system pins. some pins may not be bonded out in all implementations. table 4-1 outlines the pin names and functions and gives a brief description of their operation reset state of these pins and associated pull-ups or pull-downs is dependent on the mode of operation and on the integration of this block at the chip level (chip dependent).
chapter 4 multiplexed external bus interface (mebiv3) 132 mc9s12q128 freescale semiconductor rev 1.09 . table 4-1. external system pins associated with mebi pin name pin functions description bkgd/modc/ t a ghi modc at the rising edge on reset, the state of this pin is registered into the modc bit to set the mode. (this pin always has an internal pullup.) bkgd pseudo open-drain communication pin for the single-wire background debug mode. there is an internal pull-up resistor on this pin. t a ghi when instruction tagging is on, a 0 at the falling edge of e tags the high half of the instruction word being read into the instruction queue. pa7/a15/d15/d7 thru pa0/a8/d8/d0 pa7?a0 general-purpose i/o pins, see porta and ddra registers. a15?8 high-order address lines multiplexed during eclk low. outputs except in special peripheral mode where they are inputs from an external tester system. d15?8 high-order bidirectional data lines multiplexed during eclk high in expanded wide modes, special peripheral mode, and visible internal accesses (ivis = 1) in emulation expanded narrow mode. direction of data transfer is generally indicated by r/ w. d15/d7 thru d8/d0 alternate high-order and low-order bytes of the bidirectional data lines multiplexed during eclk high in expanded narrow modes and narrow accesses in wide modes. direction of data transfer is generally indicated by r/ w. pb7/a7/d7 thru pb0/a0/d0 pb7?b0 general-purpose i/o pins, see portb and ddrb registers. a7?0 low-order address lines multiplexed during eclk low. outputs except in special peripheral mode where they are inputs from an external tester system. d7?0 low-order bidirectional data lines multiplexed during eclk high in expanded wide modes, special peripheral mode, and visible internal accesses (with ivis = 1) in emulation expanded narrow mode. direction of data transfer is generally indicated by r/ w. pe7/noacc pe7 general-purpose i/o pin, see porte and ddre registers. noacc cpu no access output. indicates whether the current cycle is a free cycle. only available in expanded modes. pe6/ipipe1/ modb/clkto modb at the rising edge of reset, the state of this pin is registered into the modb bit to set the mode. pe6 general-purpose i/o pin, see porte and ddre registers. ipipe1 instruction pipe status bit 1, enabled by pipoe bit in pear. clkto system clock test output. only available in special modes. pipoe = 1 overrides this function. the enable for this function is in the clock module. pe5/ipipe0/moda moda at the rising edge on reset, the state of this pin is registered into the moda bit to set the mode. pe5 general-purpose i/o pin, see porte and ddre registers. ipipe0 instruction pipe status bit 0, enabled by pipoe bit in pear.
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 133 rev 1.09 detailed descriptions of these pins can be found in the device overview chapter. 4.3 memory map and register de?ition a summary of the registers associated with the mebi sub-block is shown in table 4-2 . detailed descriptions of the registers and bits are given in the subsections that follow. on most chips the registers are mappable. therefore, the upper bits may not be all 0s as shown in the table and descriptions. pe4/eclk pe4 general-purpose i/o pin, see porte and ddre registers. eclk bus timing reference clock, can operate as a free-running clock at the system clock rate or to produce one low-high clock per visible access, with the high period stretched for slow accesses. eclk is controlled by the neclk bit in pear, the ivis bit in mode, and the estr bit in ebictl. pe3/ lstrb/ t a glo pe3 general-purpose i/o pin, see porte and ddre registers. lstrb low strobe bar, 0 indicates valid data on d7?0. sz8 in special peripheral mode, this pin is an input indicating the size of the data transfer (0 = 16-bit; 1 = 8-bit). t a glo in expanded wide mode or emulation narrow modes, when instruction tagging is on and low strobe is enabled, a 0 at the falling edge of e tags the low half of the instruction word being read into the instruction queue. pe2/r/ w pe2 general-purpose i/o pin, see porte and ddre registers. r/ w read/write, indicates the direction of internal data transfers. this is an output except in special peripheral mode where it is an input. pe1/ irq pe1 general-purpose input-only pin, can be read even if irq enabled. irq maskable interrupt request, can be level sensitive or edge sensitive. pe0/ xirq pe0 general-purpose input-only pin. xirq non-maskable interrupt input. pk7/ ecs pk7 general-purpose i/o pin, see portk and ddrk registers. ecs emulation chip select pk6/ xcs pk6 general-purpose i/o pin, see portk and ddrk registers. xcs external data chip select pk5/x19 thru pk0/x14 pk5?k0 general-purpose i/o pins, see portk and ddrk registers. x19?14 memory expansion addresses table 4-1. external system pins associated with mebi (continued) pin name pin functions description
chapter 4 multiplexed external bus interface (mebiv3) 134 mc9s12q128 freescale semiconductor rev 1.09 4.3.1 module memory map 4.3.2 register descriptions 4.3.2.1 port a data register (porta) table 4-2. mebi memory map address offset use access 0x0000 port a data register (porta) r/w 0x0001 port b data register (portb) r/w 0x0002 data direction register a (ddra) r/w 0x0003 data direction register b (ddrb) r/w 0x0004 reserved r 0x0005 reserved r 0x0006 reserved r 0x0007 reserved r 0x0008 port e data register (porte) r/w 0x0009 data direction register e (ddre) r/w 0x000a port e assignment register (pear) r/w 0x000b mode register (mode) r/w 0x000c pull control register (pucr) r/w 0x000d reduced drive register (rdriv) r/w 0x000e external bus interface control register (ebictl) r/w 0x000f reserved r 0x001e irq control register (irqcr) r/w 0x00032 port k data register (portk) r/w 0x00033 data direction register k (ddrk) r/w module base + 0x0000 starting address location affected by initrg register setting. 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 0 0 0 0 0 0 0 0 single chip pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 expanded wide, emulation narrow with ivis, and peripheral ab/db15 ab/db14 ab/db13 ab/db12 ab/db11 ab/db10 ab/db9 ab/db8 expanded narrow ab15 and db15/db7 ab14 and db14/db6 ab13 and db13/db5 ab12 and db12/db4 ab11 and db11/db3 ab10 and db10/db2 ab9 and db9/db1 ab8 and db8/db0 figure 4-2. port a data register (porta)
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 135 rev 1.09 read: anytime when register is in the map write: anytime when register is in the map port a bits 7 through 0 are associated with address lines a15 through a8 respectively and data lines d15/d7 through d8/d0 respectively. when this port is not used for external addresses such as in single- chip mode, these pins can be used as general-purpose i/o. data direction register a (ddra) determines the primary direction of each pin. ddra also determines the source of data for a read of porta. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. note to ensure that you read the value present on the porta pins, always wait at least one cycle after writing to the ddra register before reading from the porta register. 4.3.2.2 port b data register (portb) read: anytime when register is in the map write: anytime when register is in the map port b bits 7 through 0 are associated with address lines a7 through a0 respectively and data lines d7 through d0 respectively. when this port is not used for external addresses, such as in single-chip mode, these pins can be used as general-purpose i/o. data direction register b (ddrb) determines the primary direction of each pin. ddrb also determines the source of data for a read of portb. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. note to ensure that you read the value present on the portb pins, always wait at least one cycle after writing to the ddrb register before reading from the portb register. module base + 0x0001 starting address location affected by initrg register setting. 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 0 0 0 0 0 0 0 0 single chip pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 expanded wide, emulation narrow with ivis, and peripheral ab/db7 ab/db6 ab/db5 ab/db4 ab/db3 ab/db2 ab/db1 ab/db0 expanded narrow ab7 ab6 ab5 ab4 ab3 ab2 ab1 ab0 figure 4-3. port a data register (portb)
chapter 4 multiplexed external bus interface (mebiv3) 136 mc9s12q128 freescale semiconductor rev 1.09 4.3.2.3 data direction register a (ddra) read: anytime when register is in the map write: anytime when register is in the map this register controls the data direction for port a. when port a is operating as a general-purpose i/o port, ddra determines the primary direction for each port a pin. a 1 causes the associated port pin to be an output and a 0 causes the associated pin to be a high-impedance input. the value in a ddr bit also affects the source of data for reads of the corresponding porta register. if the ddr bit is 0 (input) the buffered pin input state is read. if the ddr bit is 1 (output) the associated port data register bit state is read. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. it is reset to 0x00 so the ddr does not override the three-state control signals. module base + 0x0002 starting address location affected by initrg register setting. 76543210 r bit 7 6 5 4321 bit 0 w reset 0 0 0 00000 figure 4-4. data direction register a (ddra) table 4-3. ddra field descriptions field description 7:0 ddra data direction port a 0 con?ure the corresponding i/o pin as an input 1 con?ure the corresponding i/o pin as an output
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 137 rev 1.09 4.3.2.4 data direction register b (ddrb) read: anytime when register is in the map write: anytime when register is in the map this register controls the data direction for port b. when port b is operating as a general-purpose i/o port, ddrb determines the primary direction for each port b pin. a 1 causes the associated port pin to be an output and a 0 causes the associated pin to be a high-impedance input. the value in a ddr bit also affects the source of data for reads of the corresponding portb register. if the ddr bit is 0 (input) the buffered pin input state is read. if the ddr bit is 1 (output) the associated port data register bit state is read. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. it is reset to 0x00 so the ddr does not override the three-state control signals. module base + 0x0003 starting address location affected by initrg register setting. 76543210 r bit 7 6 5 4321 bit 0 w reset 0 0 0 00000 figure 4-5. data direction register b (ddrb) table 4-4. ddrb field descriptions field description 7:0 ddrb data direction port b 0 con?ure the corresponding i/o pin as an input 1 con?ure the corresponding i/o pin as an output
chapter 4 multiplexed external bus interface (mebiv3) 138 mc9s12q128 freescale semiconductor rev 1.09 4.3.2.5 reserved registers module base + 0x0004 starting address location affected by initrg register setting. 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 4-6. reserved register module base + 0x0005 starting address location affected by initrg register setting. 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 4-7. reserved register module base + 0x0006 starting address location affected by initrg register setting. 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 4-8. reserved register module base + 0x0007 starting address location affected by initrg register setting. 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 4-9. reserved register
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 139 rev 1.09 these register locations are not used (reserved). all unused registers and bits in this block return logic 0s when read. writes to these registers have no effect. these registers are not in the on-chip map in special peripheral mode. 4.3.2.6 port e data register (porte) read: anytime when register is in the map write: anytime when register is in the map port e is associated with external bus control signals and interrupt inputs. these include mode select (modb/ipipe1, moda/ipipe0), e clock, size ( lstrb/ t a glo), read/write (r/ w), irq, and xirq. when not used for one of these speci? functions, port e pins 7:2 can be used as general-purpose i/o and pins 1:0 can be used as general-purpose input. the port e assignment register (pear) selects the function of each pin and ddre determines whether each pin is an input or output when it is con?ured to be general-purpose i/o. ddre also determines the source of data for a read of porte. some of these pins have software selectable pull resistors. irq and xirq can only be pulled up whereas the polarity of the pe7, pe4, pe3, and pe2 pull resistors are determined by chip integration. please refer to the device overview chapter (signal property summary) to determine the polarity of these resistors. a single control bit enables the pull devices for all of these pins when they are con?ured as inputs. this register is not in the on-chip map in special peripheral mode or in expanded modes when the eme bit is set. therefore, these accesses will be echoed externally. note it is unwise to write porte and ddre as a word access. if you are changing port e pins from being inputs to outputs, the data may have extra transitions during the write. it is best to initialize porte before enabling as outputs. module base + 0x0008 starting address location affected by initrg register setting. 76543210 r bit 7 65432 bit 1 bit 0 w reset 000000uu alternate pin function noacc modb or ipipe1 or clkto moda or ipipe0 eclk lstrb or t a glo r/ w irq xirq = unimplemented or reserved u = unaffected by reset figure 4-10. port e data register (porte)
chapter 4 multiplexed external bus interface (mebiv3) 140 mc9s12q128 freescale semiconductor rev 1.09 note to ensure that you read the value present on the porte pins, always wait at least one cycle after writing to the ddre register before reading from the porte register. 4.3.2.7 data direction register e (ddre) read: anytime when register is in the map write: anytime when register is in the map data direction register e is associated with port e. for bits in port e that are con?ured as general-purpose i/o lines, ddre determines the primary direction of each of these pins. a 1 causes the associated bit to be an output and a 0 causes the associated bit to be an input. port e bit 1 (associated with irq) and bit 0 (associated with xirq) cannot be con?ured as outputs. port e, bits 1 and 0, can be read regardless of whether the alternate interrupt function is enabled. the value in a ddr bit also affects the source of data for reads of the corresponding porte register. if the ddr bit is 0 (input) the buffered pin input state is read. if the ddr bit is 1 (output) the associated port data register bit state is read. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. also, it is not in the map in expanded modes while the eme control bit is set. module base + 0x0009 starting address location affected by initrg register setting. 76543210 r bit 7 6 5 4 3 bit 2 00 w reset 0 0 0 00000 = unimplemented or reserved figure 4-11. data direction register e (ddre) table 4-5. ddre field descriptions field description 7:2 ddre data direction port e 0 con?ure the corresponding i/o pin as an input 1 con?ure the corresponding i/o pin as an output note: it is unwise to write porte and ddre as a word access. if you are changing port e pins from inputs to outputs, the data may have extra transitions during the write. it is best to initialize porte before enabling as outputs.
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 141 rev 1.09 4.3.2.8 port e assignment register (pear) read: anytime (provided this register is in the map). write: each bit has speci? write conditions. please refer to the descriptions of each bit on the following pages. port e serves as general-purpose i/o or as system and bus control signals. the pear register is used to choose between the general-purpose i/o function and the alternate control functions. when an alternate control function is selected, the associated ddre bits are overridden. the reset condition of this register depends on the mode of operation because bus control signals are needed immediately after reset in some modes. in normal single-chip mode, no external bus control signals are needed so all of port e is con?ured for general-purpose i/o. in normal expanded modes, only the e clock is con?ured for its alternate bus control function and the other bits of port e are con?ured for general-purpose i/o. as the reset vector is located in external memory, the e clock is required for this access. r/ w is only needed by the system when there are external writable resources. if the normal expanded system needs any other bus control signals, pear would need to be written before any access that needed the additional signals. in special test and emulation modes, ipipe1, ipipe0, e, lstrb, and r/ w are con?ured out of reset as bus control signals. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. module base + 0x000a starting address location affected by initrg register setting. 76543210 r noacce 0 pipoe neclk lstre rdwe 00 w reset special single chip 0 0 0 0 0 0 0 0 special test 0 0 1 0 1 1 0 0 peripheral 0 0 0 0 0 0 0 0 emulation expanded narrow 10101100 emulation expanded wide 10101100 normal single chip 0 0 0 1 0 0 0 0 normal expanded narrow 00000000 normal expanded wide 0 0 0 0 0 0 0 0 = unimplemented or reserved figure 4-12. port e assignment register (pear)
chapter 4 multiplexed external bus interface (mebiv3) 142 mc9s12q128 freescale semiconductor rev 1.09 table 4-6. pear field descriptions field description 7 noacce cpu no access output enable normal: write once emulation: write never special: write anytime 1 the associated pin (port e, bit 7) is general-purpose i/o. 0 the associated pin (port e, bit 7) is output and indicates whether the cycle is a cpu free cycle. this bit has no effect in single-chip or special peripheral modes. 5 pipoe pipe status signal output enable normal: write once emulation: write never special: write anytime. 0 the associated pins (port e, bits 6:5) are general-purpose i/o. 1 the associated pins (port e, bits 6:5) are outputs and indicate the state of the instruction queue this bit has no effect in single-chip or special peripheral modes. 4 neclk no external e clock normal and special: write anytime emulation: write never 0 the associated pin (port e, bit 4) is the external e clock pin. external e clock is free-running if estr = 0 1 the associated pin (port e, bit 4) is a general-purpose i/o pin. external e clock is available as an output in all modes. 3 lstre low strobe ( lstrb) enable normal: write once emulation: write never special: write anytime. 0 the associated pin (port e, bit 3) is a general-purpose i/o pin. 1 the associated pin (port e, bit 3) is con?ured as the lstrb bus control output. if bdm tagging is enabled, t a glo is multiplexed in on the rising edge of eclk and lstrb is driven out on the falling edge of eclk. this bit has no effect in single-chip, peripheral, or normal expanded narrow modes. note: lstrb is used during external writes. after reset in normal expanded mode, lstrb is disabled to provide an extra i/o pin. if lstrb is needed, it should be enabled before any external writes. external reads do not normally need lstrb because all 16 data bits can be driven even if the system only needs 8 bits of data. 2 rdwe read/write enable normal: write once emulation: write never special: write anytime 0 the associated pin (port e, bit 2) is a general-purpose i/o pin. 1 the associated pin (port e, bit 2) is con?ured as the r/ w pin this bit has no effect in single-chip or special peripheral modes. note: r/ w is used for external writes. after reset in normal expanded mode, r/ w is disabled to provide an extra i/o pin. if r/ w is needed it should be enabled before any external writes.
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 143 rev 1.09 4.3.2.9 mode register (mode) read: anytime (provided this register is in the map). write: each bit has specific write conditions. please refer to the descriptions of each bit on the following pages. the mode register is used to establish the operating mode and other miscellaneous functions (i.e., internal visibility and emulation of port e and k). in special peripheral mode, this register is not accessible but it is reset as shown to system con?uration features. changes to bits in the mode register are delayed one cycle after the write. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. module base + 0x000b starting address location affected by initrg register setting. 76543210 r modc modb moda 0 ivis 0 emk eme w reset special single chip 0 0 0 0 0 0 0 0 emulation expanded narrow 00101011 special test 0 1 0 0 1 0 0 0 emulation expanded wide 01101011 normal single chip 1 0 0 0 0 0 0 0 normal expanded narrow 10100000 peripheral 1 1 0 0 0 0 0 0 normal expanded wide 1 1 1 0 0 0 0 0 = unimplemented or reserved figure 4-13. mode register (mode)
chapter 4 multiplexed external bus interface (mebiv3) 144 mc9s12q128 freescale semiconductor rev 1.09 table 4-7. mode field descriptions field description 7:5 mod[c:a] mode select bits ?these bits indicate the current operating mode. if moda = 1, then modc, modb, and moda are write never. if modc = moda = 0, then modc, modb, and moda are writable with the exception that you cannot change to or from special peripheral mode if modc = 1, modb = 0, and moda = 0, then modc is write never. modb and moda are write once, except that you cannot change to special peripheral mode. from normal single-chip, only normal expanded narrow and normal expanded wide modes are available. see table 4-8 and table 4-16 . 3 ivis internal visibility (for both read and write accesses) ?this bit determines whether internal accesses generate a bus cycle that is visible on the external bus. normal: write once emulation: write never special: write anytime 0 no visibility of internal bus operations on external bus. 1 internal bus operations are visible on external bus. 1 emk emulate port k normal: write once emulation: write never special: write anytime 0 portk and ddrk are in the memory map so port k can be used for general-purpose i/o. 1 if in any expanded mode, portk and ddrk are removed from the memory map. in single-chip modes, portk and ddrk are always in the map regardless of the state of this bit. in special peripheral mode, portk and ddrk are never in the map regardless of the state of this bit. 0 eme emulate port e normal and emulation: write never special: write anytime 0 porte and ddre are in the memory map so port e can be used for general-purpose i/o. 1 if in any expanded mode or special peripheral mode, porte and ddre are removed from the memory map. removing the registers from the map allows the user to emulate the function of these registers externally. in single-chip modes, porte and ddre are always in the map regardless of the state of this bit.
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 145 rev 1.09 4.3.2.10 pull control register (pucr) read: anytime (provided this register is in the map). write: anytime (provided this register is in the map). this register is used to select pull resistors for the pins associated with the core ports. pull resistors are assigned on a per-port basis and apply to any pin in the corresponding port that is currently con?ured as an input. the polarity of these pull resistors is determined by chip integration. please refer to the device overview chapter to determine the polarity of these resistors. table 4-8. modc, modb, and moda write capability (1) 1. no writes to the mod bits are allowed while operating in a secure mode. for more details, refer to the device over- view chapter. modc modb moda mode modx write capability 0 0 0 special single chip modc, modb, and moda write anytime but not to 110 (2) 2. if you are in a special single-chip or special test mode and you write to this register, changing to normal single-chip mode, then one allowed write to this register remains. if you write to normal expanded or emulation mode, then no writes remain. 0 0 1 emulation narrow no write 0 1 0 special test modc, modb, and moda write anytime but not to 110 (2) 0 1 1 emulation wide no write 1 0 0 normal single chip modc write never, modb and moda write once but not to 110 1 0 1 normal expanded narrow no write 1 1 0 special peripheral no write 1 1 1 normal expanded wide no write module base + 0x000c starting address location affected by initrg register setting. 76543210 r pupke 00 pupee 00 pupbe pupae w reset 1 10010000 notes: 1. the default value of this parameter is shown. please refer to the device overview chapter to deter- mine the actual reset state of this register. = unimplemented or reserved figure 4-14. pull control register (pucr)
chapter 4 multiplexed external bus interface (mebiv3) 146 mc9s12q128 freescale semiconductor rev 1.09 this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. note these bits have no effect when the associated pin(s) are outputs. (the pull resistors are inactive.) 4.3.2.11 reduced drive register (rdriv) read: anytime (provided this register is in the map) write: anytime (provided this register is in the map) this register is used to select reduced drive for the pins associated with the core ports. this gives reduced power consumption and reduced rfi with a slight increase in transition time (depending on loading). this feature would be used on ports which have a light loading. the reduced drive function is independent of which function is being used on a particular port. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. table 4-9. pucr field descriptions field description 7 pupke pull resistors port k enable 0 port k pull resistors are disabled. 1 enable pull resistors for port k input pins. 4 pupee pull resistors port e enable 0 port e pull resistors on bits 7, 4:0 are disabled. 1 enable pull resistors for port e input pins bits 7, 4:0. note: pins 5 and 6 of port e have pull resistors which are only enabled during reset. this bit has no effect on these pins. 1 pupbe pull resistors port b enable 0 port b pull resistors are disabled. 1 enable pull resistors for all port b input pins. 0 pupae pull resistors port a enable 0 port a pull resistors are disabled. 1 enable pull resistors for all port a input pins. module base + 0x000d starting address location affected by initrg register setting. 76543210 r rdrk 00 rdpe 00 rdpb rdpa w reset 00000000 = unimplemented or reserved figure 4-15. reduced drive register (rdriv)
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 147 rev 1.09 4.3.2.12 external bus interface control register (ebictl) read: anytime (provided this register is in the map) write: refer to individual bit descriptions below the ebictl register is used to control miscellaneous functions (i.e., stretching of external e clock). this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. table 4-10. rdriv field descriptions field description 7 rdrk reduced drive of port k 0 all port k output pins have full drive enabled. 1 all port k output pins have reduced drive enabled. 4 rdpe reduced drive of port e 0 all port e output pins have full drive enabled. 1 all port e output pins have reduced drive enabled. 1 rdpb reduced drive of port b 0 all port b output pins have full drive enabled. 1 all port b output pins have reduced drive enabled. 0 rdpa reduced drive of ports a 0 all port a output pins have full drive enabled. 1 all port a output pins have reduced drive enabled. module base + 0x000e starting address location affected by initrg register setting. 76543210 r0000000 estr w reset: peripheral all other modes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 = unimplemented or reserved figure 4-16. external bus interface control register (ebictl) table 4-11. ebictl field descriptions field description 0 estr e clock stretches this control bit determines whether the e clock behaves as a simple free-running clock or as a bus control signal that is active only for external bus cycles. normal and emulation: write once special: write anytime 0 e never stretches (always free running). 1 e stretches high during stretched external accesses and remains low during non-visible internal accesses. this bit has no effect in single-chip modes.
chapter 4 multiplexed external bus interface (mebiv3) 148 mc9s12q128 freescale semiconductor rev 1.09 4.3.2.13 reserved register this register location is not used (reserved). all bits in this register return logic 0s when read. writes to this register have no effect. this register is not in the on-chip memory map in expanded and special peripheral modes. therefore, these accesses will be echoed externally. 4.3.2.14 irq control register (irqcr) read: see individual bit descriptions below write: see individual bit descriptions below module base + 0x000f starting address location affected by initrg register setting. 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 4-17. reserved register module base + 0x001e starting address location affected by initrg register setting. 76543210 r irqe irqen 000000 w reset 01000000 = unimplemented or reserved figure 4-18. irq control register (irqcr) table 4-12. irqcr field descriptions field description 7 irqe irq select edge sensitive only special modes: read or write anytime normal and emulation modes: read anytime, write once 0 irq con?ured for low level recognition. 1 irq con?ured to respond only to falling edges. falling edges on the irq pin will be detected anytime irqe = 1 and will be cleared only upon a reset or the servicing of the irq interrupt. 6 irqen external irq enable normal, emulation, and special modes: read or write anytime 0 external irq pin is disconnected from interrupt logic. 1 external irq pin is connected to interrupt logic. note: when irqen = 0, the edge detect latch is disabled.
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 149 rev 1.09 4.3.2.15 port k data register (portk) read: anytime write: anytime this port is associated with the internal memory expansion emulation pins. when the port is not enabled to emulate the internal memory expansion, the port pins are used as general-purpose i/o. when port k is operating as a general-purpose i/o port, ddrk determines the primary direction for each port k pin. a 1 causes the associated port pin to be an output and a 0 causes the associated pin to be a high-impedance input. the value in a ddr bit also affects the source of data for reads of the corresponding portk register. if the ddr bit is 0 (input) the buffered pin input is read. if the ddr bit is 1 (output) the output of the port data register is read. this register is not in the map in peripheral or expanded modes while the emk control bit in mode register is set. therefore, these accesses will be echoed externally. when inputs, these pins can be selected to be high impedance or pulled up, based upon the state of the pupke bit in the pucr register. module base + 0x0032 starting address location affected by initrg register setting. 76543210 r bit 7 654321 bit 0 w reset 00000000 alternate pin function ecs xcs xab19 xab18 xab17 xab16 xab15 xab14 figure 4-19. port k data register (portk) table 4-13. portk field descriptions field description 7 port k, bit 7 port k, bit 7 ?this bit is used as an emulation chip select signal for the emulation of the internal memory expansion, or as general-purpose i/o, depending upon the state of the emk bit in the mode register. while this bit is used as a chip select, the external bit will return to its de-asserted state (v dd ) for approximately 1/4 cycle just after the negative edge of eclk, unless the external access is stretched and eclk is free-running (estr bit in ebictl = 0). see the mmc block description chapter for additional details on when this signal will be active. 6 port k, bit 6 port k, bit 6 ?this bit is used as an external chip select signal for most external accesses that are not selected by ecs (see the mmc block description chapter for more details), depending upon the state the of the emk bit in the mode register. while this bit is used as a chip select, the external pin will return to its de- asserted state (v dd ) for approximately 1/4 cycle just after the negative edge of eclk, unless the external access is stretched and eclk is free-running (estr bit in ebictl = 0). 5:0 port k, bits 5:0 port k, bits 5:0 these six bits are used to determine which flash/rom or external memory array page is being accessed. they can be viewed as expanded addresses xab19?ab14 of the 20-bit address used to access up to1m byte internal flash/rom or external memory array. alternatively, these bits can be used for general-purpose i/o depending upon the state of the emk bit in the mode register.
chapter 4 multiplexed external bus interface (mebiv3) 150 mc9s12q128 freescale semiconductor rev 1.09 4.3.2.16 port k data direction register (ddrk) read: anytime write: anytime this register determines the primary direction for each port k pin con?ured as general-purpose i/o. this register is not in the map in peripheral or expanded modes while the emk control bit in mode register is set. therefore, these accesses will be echoed externally. 4.4 functional description 4.4.1 detecting access type from external signals the external signals lstrb, r/ w, and ab0 indicate the type of bus access that is taking place. accesses to the internal ram module are the only type of access that would produce lstrb = ab0 = 1, because the internal ram is speci?ally designed to allow misaligned 16-bit accesses in a single cycle. in these cases the data for the address that was accessed is on the low half of the data bus and the data for address + 1 is on the high half of the data bus. this is summarized in table 4-15 . module base + 0x0033 starting address location affected by initrg register setting. 76543210 r bit 7 654321 bit 0 w reset 00000000 figure 4-20. port k data direction register (ddrk) table 4-14. ebictl field descriptions field description 7:0 ddrk data direction port k bits 0 associated pin is a high-impedance input 1 associated pin is an output note: it is unwise to write portk and ddrk as a word access. if you are changing port k pins from inputs to outputs, the data may have extra transitions during the write. it is best to initialize portk before enabling as outputs. note: to ensure that you read the correct value from the portk pins, always wait at least one cycle after writing to the ddrk register before reading from the portk register. table 4-15. access type vs. bus control pins lstrb ab0 r/ w type of access 1 0 1 8-bit read of an even address 0 1 1 8-bit read of an odd address 1 0 0 8-bit write of an even address 0 1 0 8-bit write of an odd address
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 151 rev 1.09 4.4.2 stretched bus cycles in order to allow fast internal bus cycles to coexist in a system with slower external memory resources, the hcs12 supports the concept of stretched bus cycles (module timing reference clocks for timers and baud rate generators are not affected by this stretching). control bits in the misc register in the mmc sub-block of the core specify the amount of stretch (0, 1, 2, or 3 periods of the internal bus-rate clock). while stretching, the cpu state machines are all held in their current state. at this point in the cpu bus cycle, write data would already be driven onto the data bus so the length of time write data is valid is extended in the case of a stretched bus cycle. read data would not be captured by the system until the e clock falling edge. in the case of a stretched bus cycle, read data is not required until the speci?d setup time before the falling edge of the stretched e clock. the chip selects, and r/ w signals remain valid during the period of stretching (throughout the stretched e high time). note the address portion of the bus cycle is not stretched . 4.4.3 modes of operation the operating mode out of reset is determined by the states of the modc, modb, and moda pins during reset ( table 4-16 ). the modc, modb, and moda bits in the mode register show the current operating mode and provide limited mode switching during operation. the states of the modc, modb, and moda pins are latched into these bits on the rising edge of the reset signal. 0 0 1 16-bit read of an even address 1 1 1 16-bit read of an odd address (low/high data swapped) 0 0 0 16-bit write to an even address 1 1 0 16-bit write to an odd address (low/high data swapped) table 4-16. mode selection modc modb moda mode description 0 0 0 special single chip, bdm allowed and active. bdm is allowed in all other modes but a serial command is required to make bdm active. 0 0 1 emulation expanded narrow, bdm allowed 0 1 0 special test (expanded wide), bdm allowed 0 1 1 emulation expanded wide, bdm allowed 1 0 0 normal single chip, bdm allowed 1 0 1 normal expanded narrow, bdm allowed 1 1 0 peripheral; bdm allowed but bus operations would cause bus con?cts (must not be used) 1 1 1 normal expanded wide, bdm allowed table 4-15. access type vs. bus control pins lstrb ab0 r/ w type of access
chapter 4 multiplexed external bus interface (mebiv3) 152 mc9s12q128 freescale semiconductor rev 1.09 there are two basic types of operating modes: 1. normal modes: some registers and bits are protected against accidental changes. 2. special modes: allow greater access to protected control registers and bits for special purposes such as testing. a system development and debug feature, background debug mode (bdm), is available in all modes. in special single-chip mode, bdm is active immediately after reset. some aspects of port e are not mode dependent. bit 1 of port e is a general purpose input or the irq interrupt input. irq can be enabled by bits in the cpus condition codes register but it is inhibited at reset so this pin is initially con?ured as a simple input with a pull-up. bit 0 of port e is a general purpose input or the xirq interrupt input. xirq can be enabled by bits in the cpus condition codes register but it is inhibited at reset so this pin is initially con?ured as a simple input with a pull-up. the estr bit in the ebictl register is set to one by reset in any user mode. this assures that the reset vector can be fetched even if it is located in an external slow memory device. the pe6/modb/ipipe1 and pe5/moda/ipipe0 pins act as high-impedance mode select inputs during reset. the following paragraphs discuss the default bus setup and describe which aspects of the bus can be changed after reset on a per mode basis. 4.4.3.1 normal operating modes these modes provide three operating con?urations. background debug is available in all three modes, but must ?st be enabled for some operations by means of a bdm background command, then activated. 4.4.3.1.1 normal single-chip mode there is no external expansion bus in this mode. all pins of ports a, b and e are con?ured as general purpose i/o pins port e bits 1 and 0 are available as general purpose input only pins with internal pull resistors enabled. all other pins of port e are bidirectional i/o pins that are initially con?ured as high- impedance inputs with internal pull resistors enabled. ports a and b are con?ured as high-impedance inputs with their internal pull resistors disabled. the pins associated with port e bits 6, 5, 3, and 2 cannot be con?ured for their alternate functions ipipe1, ipipe0, lstrb, and r/ w while the mcu is in single chip modes. in single chip modes, the associated control bits pipoe, lstre, and rdwe are reset to zero. writing the opposite state into them in single chip mode does not change the operation of the associated port e pins. in normal single chip mode, the mode register is writable one time. this allows a user program to change the bus mode to narrow or wide expanded mode and/or turn on visibility of internal accesses. port e, bit 4 can be con?ured for a free-running e clock output by clearing neclk=0. typically the only use for an e clock output while the mcu is in single chip modes would be to get a constant speed clock for use in the external application system.
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 153 rev 1.09 4.4.3.1.2 normal expanded wide mode in expanded wide modes, ports a and b are con?ured as a 16-bit multiplexed address and data bus and port e bit 4 is con?ured as the e clock output signal. these signals allow external memory and peripheral devices to be interfaced to the mcu. port e pins other than pe4/eclk are con?ured as general purpose i/o pins (initially high-impedance inputs with internal pull resistors enabled). control bits pipoe, neclk, lstre, and rdwe in the pear register can be used to con?ure port e pins to act as bus control outputs instead of general purpose i/o pins. it is possible to enable the pipe status signals on port e bits 6 and 5 by setting the pipoe bit in pear, but it would be unusual to do so in this mode. development systems where pipe status signals are monitored would typically use the special variation of this mode. the port e bit 2 pin can be recon?ured as the r/ w bus control signal by writing ? to the rdwe bit in pear. if the expanded system includes external devices that can be written, such as ram, the rdwe bit would need to be set before any attempt to write to an external location. if there are no writable resources in the external system, pe2 can be left as a general purpose i/o pin. the port e bit 3 pin can be recon?ured as the lstrb bus control signal by writing ? to the lstre bit in pear. the default condition of this pin is a general purpose input because the lstrb function is not needed in all expanded wide applications. the port e bit 4 pin is initially con?ured as eclk output with stretch. the e clock output function depends upon the settings of the neclk bit in the pear register, the ivis bit in the mode register and the estr bit in the ebictl register. the e clock is available for use in external select decode logic or as a constant speed clock for use in the external application system. 4.4.3.1.3 normal expanded narrow mode this mode is used for lower cost production systems that use 8-bit wide external eproms or rams. such systems take extra bus cycles to access 16-bit locations but this may be preferred over the extra cost of additional external memory devices. ports a and b are con?ured as a 16-bit address bus and port a is multiplexed with data. internal visibility is not available in this mode because the internal cycles would need to be split into two 8-bit cycles. since the pear register can only be written one time in this mode, use care to set all bits to the desired states during the single allowed write. the pe3/ lstrb pin is always a general purpose i/o pin in normal expanded narrow mode. although it is possible to write the lstre bit in pear to ??in this mode, the state of lstre is overridden and port e bit 3 cannot be recon?ured as the lstrb output. it is possible to enable the pipe status signals on port e bits 6 and 5 by setting the pipoe bit in pear, but it would be unusual to do so in this mode. lstrb would also be needed to fully understand system activity. development systems where pipe status signals are monitored would typically use special expanded wide mode or occasionally special expanded narrow mode.
chapter 4 multiplexed external bus interface (mebiv3) 154 mc9s12q128 freescale semiconductor rev 1.09 the pe4/eclk pin is initially con?ured as eclk output with stretch. the e clock output function depends upon the settings of the neclk bit in the pear register, the ivis bit in the mode register and the estr bit in the ebictl register. in normal expanded narrow mode, the e clock is available for use in external select decode logic or as a constant speed clock for use in the external application system. the pe2/r/w pin is initially con?ured as a general purpose input with an internal pull resistor enabled but this pin can be recon?ured as the r/ w bus control signal by writing ??to the rdwe bit in pear. if the expanded narrow system includes external devices that can be written such as ram, the rdwe bit would need to be set before any attempt to write to an external location. if there are no writable resources in the external system, pe2 can be left as a general purpose i/o pin. 4.4.3.1.4 emulation expanded wide mode in expanded wide modes, ports a and b are con?ured as a 16-bit multiplexed address and data bus and port e provides bus control and status signals. these signals allow external memory and peripheral devices to be interfaced to the mcu. these signals can also be used by a logic analyzer to monitor the progress of application programs. the bus control related pins in port e (pe7/noacc, pe6/modb/ipipe1, pe5/moda/ipipe0, pe4/eclk, pe3/ lstrb/ t a glo, and pe2/r/ w) are all con?ured to serve their bus control output functions rather than general purpose i/o. notice that writes to the bus control enable bits in the pear register in emulation mode are restricted. 4.4.3.1.5 emulation expanded narrow mode expanded narrow modes are intended to allow connection of single 8-bit external memory devices for lower cost systems that do not need the performance of a full 16-bit external data bus. accesses to internal resources that have been mapped external (i.e. porta, portb, ddra, ddrb, porte, ddre, pear, pucr, rdriv) will be accessed with a 16-bit data bus on ports a and b. accesses of 16-bit external words to addresses which are normally mapped external will be broken into two separate 8-bit accesses using port a as an 8-bit data bus. internal operations continue to use full 16-bit data paths. they are only visible externally as 16-bit information if ivis=1. ports a and b are configured as multiplexed address and data output ports. during external accesses, address a15, data d15 and d7 are associated with pa7, address a0 is associated with pb0 and data d8 and d0 are associated with pa0. during internal visible accesses and accesses to internal resources that have been mapped external, address a15 and data d15 is associated with pa7 and address a0 and data d0 is associated with pb0. the bus control related pins in port e (pe7/noacc, pe6/modb/ipipe1, pe5/moda/ipipe0, pe4/eclk, pe3/ lstrb/ taglo, and pe2/r/ w) are all configured to serve their bus control output functions rather than general purpose i/o. notice that writes to the bus control enable bits in the pear register in emulation mode are restricted. the main difference between special modes and normal modes is that some of the bus control and system control signals cannot be written in emulation modes.
chapter 4 multiplexed external bus interface (mebiv3) freescale semiconductor mc9s12q128 155 rev 1.09 4.4.3.2 special operating modes there are two special operating modes that correspond to normal operating modes. these operating modes are commonly used in factory testing and system development. 4.4.3.2.1 special single-chip mode when the mcu is reset in this mode, the background debug mode is enabled and active. the mcu does not fetch the reset vector and execute application code as it would in other modes. instead the active background mode is in control of cpu execution and bdm firmware is waiting for additional serial commands through the bkgd pin. when a serial command instructs the mcu to return to normal execution, the system will be configured as described below unless the reset states of internal control registers have been changed through background commands after the mcu was reset. there is no external expansion bus after reset in this mode. ports a and b are initially simple bidirectional i/o pins that are configured as high-impedance inputs with internal pull resistors disabled; however, writing to the mode select bits in the mode register (which is allowed in special modes) can change this after reset. all of the port e pins (except pe4/eclk) are initially configured as general purpose high- impedance inputs with internal pull resistors enabled. pe4/eclk is configured as the e clock output in this mode. the pins associated with port e bits 6, 5, 3, and 2 cannot be configured for their alternate functions ipipe1, ipipe0, lstrb, and r/ w while the mcu is in single chip modes. in single chip modes, the associated control bits pipoe, lstre and rdwe are reset to zero. writing the opposite value into these bits in single chip mode does not change the operation of the associated port e pins. port e, bit 4 can be configured for a free-running e clock output by clearing neclk=0. typically the only use for an e clock output while the mcu is in single chip modes would be to get a constant speed clock for use in the external application system. 4.4.3.2.2 special test mode in expanded wide modes, ports a and b are configured as a 16-bit multiplexed address and data bus and port e provides bus control and status signals. in special test mode, the write protection of many control bits is lifted so that they can be thoroughly tested without needing to go through reset. 4.4.3.3 test operating mode there is a test operating mode in which an external master, such as an i.c. tester, can control the on-chip peripherals. 4.4.3.3.1 peripheral mode this mode is intended for factory testing of the mcu. in this mode, the cpu is inactive and an external (tester) bus master drives address, data and bus control signals in through ports a, b and e. in effect, the whole mcu acts as if it was a peripheral under control of an external cpu. this allows faster testing of on-chip memory and peripherals than previous testing methods. since the mode control register is not accessible in peripheral mode, the only way to change to another mode is to reset the mcu into a different
chapter 4 multiplexed external bus interface (mebiv3) 156 mc9s12q128 freescale semiconductor rev 1.09 mode. background debugging should not be used while the mcu is in special peripheral mode as internal bus conflicts between bdm and the external master can cause improper operation of both functions. 4.4.4 internal visibility internal visibility is available when the mcu is operating in expanded wide modes or emulation narrow mode. it is not available in single-chip, peripheral or normal expanded narrow modes. internal visibility is enabled by setting the ivis bit in the mode register. if an internal access is made while e, r/ w, and lstrb are con?ured as bus control outputs and internal visibility is off (ivis=0), e will remain low for the cycle, r/ w will remain high, and address, data and the lstrb pins will remain at their previous state. when internal visibility is enabled (ivis=1), certain internal cycles will be blocked from going external. during cycles when the bdm is selected, r/ w will remain high, data will maintain its previous state, and address and lstrb pins will be updated with the internal value. during cpu no access cycles when the bdm is not driving, r/ w will remain high, and address, data and the lstrb pins will remain at their previous state. note when the system is operating in a secure mode, internal visibility is not available (i.e., ivis = 1 has no effect). also, the ipipe signals will not be visible, regardless of operating mode. ipipe1?pipe0 will display 0es if they are enabled. in addition, the mod bits in the mode control register cannot be written. 4.4.5 low-power options the mebi does not contain any user-controlled options for reducing power consumption. the operation of the mebi in low-power modes is discussed in the following subsections. 4.4.5.1 operation in run mode the mebi does not contain any options for reducing power in run mode; however, the external addresses are conditioned to reduce power in single-chip modes. expanded bus modes will increase power consumption. 4.4.5.2 operation in wait mode the mebi does not contain any options for reducing power in wait mode. 4.4.5.3 operation in stop mode the mebi will cease to function after execution of a cpu stop instruction.
freescale semiconductor mc9s12q128 157 rev 1.09 chapter 5 interrupt (intv1) block description 5.1 introduction this section describes the functionality of the interrupt (int) sub-block of the s12 core platform. a block diagram of the interrupt sub-block is shown in figure 5-1 . figure 5-1. intv1 block diagram hprio (optional) int priority decoder vector request interrupts reset flags write data bus hprio vector xmask imask qualified interrupt input registers interrupts and control registers highest priority i-interrupt read data bus wakeup vector address interrupt pending
chapter 5 interrupt (intv1) block description 158 mc9s12q128 freescale semiconductor rev 1.09 the interrupt sub-block decodes the priority of all system exception requests and provides the applicable vector for processing the exception. the int supports i-bit maskable and x-bit maskable interrupts, a non- maskable unimplemented opcode trap, a non-maskable software interrupt (swi) or background debug mode request, and three system reset vector requests. all interrupt related exception requests are managed by the interrupt sub-block (int). 5.1.1 features the int includes these features: provides two to 122 i-bit maskable interrupt vectors (0xff00?xfff2) provides one x-bit maskable interrupt vector (0xfff4) provides a non-maskable software interrupt (swi) or background debug mode request vector (0xfff6) provides a non-maskable unimplemented opcode trap (trap) vector (0xfff8) provides three system reset vectors (0xfffa?xfffe) (reset, cmr, and cop) determines the appropriate vector and drives it onto the address bus at the appropriate time signals the cpu that interrupts are pending provides control registers which allow testing of interrupts provides additional input signals which prevents requests for servicing i and x interrupts wakes the system from stop or wait mode when an appropriate interrupt occurs or whenever xirq is active, even if xirq is masked provides asynchronous path for all i and x interrupts, (0xff00?xfff4) (optional) selects and stores the highest priority i interrupt based on the value written into the hprio register 5.1.2 modes of operation the functionality of the int sub-block in various modes of operation is discussed in the subsections that follow. normal operation the int operates the same in all normal modes of operation. special operation interrupts may be tested in special modes through the use of the interrupt test registers. emulation modes the int operates the same in emulation modes as in normal modes. low power modes see section 5.4.1, ?ow-power modes , for details
chapter 5 interrupt (intv1) block description freescale semiconductor mc9s12q128 159 rev 1.09 5.2 external signal description most interfacing with the interrupt sub-block is done within the core. however, the interrupt does receive direct input from the multiplexed external bus interface (mebi) sub-block of the core for the irq and xirq pin data. 5.3 memory map and register de?ition detailed descriptions of the registers and associated bits are given in the subsections that follow. 5.3.1 module memory map 5.3.2 register descriptions 5.3.2.1 interrupt test control register read: see individual bit descriptions write: see individual bit descriptions table 5-1. int memory map address offset use access 0x0015 interrupt test control register (itcr) r/w 0x0016 interrupt test registers (itest) r/w 0x001f highest priority interrupt (optional) (hprio) r/w module base + 0x0015 starting address location affected by initrg register setting. 76543210 r000 wrtint adr3 adr2 adr1 adr0 w reset 0 0 0 01111 = unimplemented or reserved figure 5-2. interrupt test control register (itcr)
chapter 5 interrupt (intv1) block description 160 mc9s12q128 freescale semiconductor rev 1.09 5.3.2.2 interrupt test registers read: only in special modes. reads will return either the state of the interrupt inputs of the interrupt sub- block (wrtint = 0) or the values written into the test registers (wrtint = 1). reads will always return 0s in normal modes. write: only in special modes and with wrtint = 1 and ccr i mask = 1. table 5-2. itcr field descriptions field description 4 wrtint write to the interrupt test registers read: anytime write: only in special modes and with i-bit mask and x-bit mask set. 0 disables writes to the test registers; reads of the test registers will return the state of the interrupt inputs. 1 disconnect the interrupt inputs from the priority decoder and use the values written into the itest registers instead. note: any interrupts which are pending at the time that wrtint is set will remain until they are overwritten. 3:0 adr[3:0] test register select bits read: anytime write: anytime these bits determine which test register is selected on a read or write. the hexadecimal value written here will be the same as the upper nibble of the lower byte of the vector selects. that is, an ? written into adr[3:0] will select vectors 0xfffe?xfff0 while a ??written to adr[3:0] will select vectors 0xff7e?xff70. module base + 0x0016 starting address location affected by initrg register setting. 76543210 r inte intc inta int8 int6 int4 int2 int0 w reset 0 0 0 00000 = unimplemented or reserved figure 5-3. interrupt test registers (itest)
chapter 5 interrupt (intv1) block description freescale semiconductor mc9s12q128 161 rev 1.09 5.3.2.3 highest priority i interrupt (optional) read: anytime write: only if i mask in ccr = 1 5.4 functional description the interrupt sub-block processes all exception requests made by the cpu. these exceptions include interrupt vector requests and reset vector requests. each of these exception types and their overall priority level is discussed in the subsections below. table 5-3. itest field descriptions field description 7:0 int[e:0] interrupt test bits ?these registers are used in special modes for testing the interrupt logic and priority independent of the system con?uration. each bit is used to force a speci? interrupt vector by writing it to a logic 1 state. bits are named inte through int0 to indicate vectors 0xffxe through 0xffx0. these bits can be written only in special modes and only with the wrtint bit set (logic 1) in the interrupt test control register (itcr). in addition, i interrupts must be masked using the i bit in the ccr. in this state, the interrupt input lines to the interrupt sub-block will be disconnected and interrupt requests will be generated only by this register. these bits can also be read in special modes to view that an interrupt requested by a system block (such as a peripheral block) has reached the int module. there is a test register implemented for every eight interrupts in the overall system. all of the test registers share the same address and are individually selected using the value stored in the adr[3:0] bits of the interrupt test control register (itcr). note: when adr[3:0] have the value of 0x000f, only bits 2:0 in the itest register will be accessible. that is, vectors higher than 0xfff4 cannot be tested using the test registers and bits 7:3 will always read as a logic 0. if adr[3:0] point to an unimplemented test register, writes will have no effect and reads will always return a logic 0 value. module base + 0x001f starting address location affected by initrg register setting. 76543210 r psel7 psel6 psel5 psel4 psel3 psel2 psel1 0 w reset 1 1 1 10010 = unimplemented or reserved figure 5-4. highest priority i interrupt register (hprio) table 5-4. hprio field descriptions field description 7:1 psel[7:1] highest priority i interrupt select bits the state of these bits determines which i-bit maskable interrupt will be promoted to highest priority (of the i-bit maskable interrupts). to promote an interrupt, the user writes the least signi?ant byte of the associated interrupt vector address to this register. if an unimplemented vector address or a non i-bit masked vector address (value higher than 0x00f2) is written, irq (0xfff2) will be the default highest priority interrupt.
chapter 5 interrupt (intv1) block description 162 mc9s12q128 freescale semiconductor rev 1.09 5.4.1 low-power modes the int does not contain any user-controlled options for reducing power consumption. the operation of the int in low-power modes is discussed in the following subsections. 5.4.1.1 operation in run mode the int does not contain any options for reducing power in run mode. 5.4.1.2 operation in wait mode clocks to the int can be shut off during system wait mode and the asynchronous interrupt path will be used to generate the wake-up signal upon recognition of a valid interrupt or any xirq request. 5.4.1.3 operation in stop mode clocks to the int can be shut off during system stop mode and the asynchronous interrupt path will be used to generate the wake-up signal upon recognition of a valid interrupt or any xirq request. 5.5 resets the int supports three system reset exception request types: normal system reset or power-on-reset request, crystal monitor reset request, and cop watchdog reset request. the type of reset exception request must be decoded by the system and the proper request made to the core. the int will then provide the service routine address for the type of reset requested. 5.6 interrupts as shown in the block diagram in figure 5-1 , the int contains a register block to provide interrupt status and control, an optional highest priority i interrupt (hprio) block, and a priority decoder to evaluate whether pending interrupts are valid and assess their priority. 5.6.1 interrupt registers the int registers are accessible only in special modes of operation and function as described in section 5.3.2.1, ?nterrupt test control register , and section 5.3.2.2, ?nterrupt test registers , previously. 5.6.2 highest priority i-bit maskable interrupt when the optional hprio block is implemented, the user is allowed to promote a single i-bit maskable interrupt to be the highest priority i interrupt. the hprio evaluates all interrupt exception requests and passes the hprio vector to the priority decoder if the highest priority i interrupt is active. rti replaces the promoted interrupt source.
chapter 5 interrupt (intv1) block description freescale semiconductor mc9s12q128 163 rev 1.09 5.6.3 interrupt priority decoder the priority decoder evaluates all interrupts pending and determines their validity and priority. when the cpu requests an interrupt vector, the decoder will provide the vector for the highest priority interrupt request. because the vector is not supplied until the cpu requests it, it is possible that a higher priority interrupt request could override the original exception that caused the cpu to request the vector. in this case, the cpu will receive the highest priority vector and the system will process this exception instead of the original request. note care must be taken to ensure that all exception requests remain active until the system begins execution of the applicable service routine; otherwise, the exception request may not be processed. if for any reason the interrupt source is unknown (e.g., an interrupt request becomes inactive after the interrupt has been recognized but prior to the vector request), the vector address will default to that of the last valid interrupt that existed during the particular interrupt sequence. if the cpu requests an interrupt vector when there has never been a pending interrupt request, the int will provide the software interrupt (swi) vector address. 5.7 exception priority the priority (from highest to lowest) and address of all exception vectors issued by the int upon request by the cpu is shown in table 5-5 . table 5-5. exception vector map and priority vector address source 0xfffe?xffff system reset 0xfffc?xfffd crystal monitor reset 0xfffa?xfffb cop reset 0xfff8?xfff9 unimplemented opcode trap 0xfff6?xfff7 software interrupt instruction (swi) or bdm vector request 0xfff4?xfff5 xirq signal 0xfff2?xfff3 irq signal 0xfff0?xff00 device-speci? i-bit maskable interrupt sources (priority in descending order)
chapter 5 interrupt (intv1) block description 164 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 165 rev 1.09 chapter 6 background debug module (bdmv4) block description 6.1 introduction this section describes the functionality of the background debug module (bdm) sub-block of the hcs12 core platform. a block diagram of the bdm is shown in figure 6-1 . figure 6-1. bdm block diagram the background debug module (bdm) sub-block is a single-wire, background debug system implemented in on-chip hardware for minimal cpu intervention. all interfacing with the bdm is done via the bkgd pin. bdmv4 has enhanced capability for maintaining synchronization between the target and host while allowing more ?xibility in clock rates. this includes a sync signal to show the clock rate and a handshake signal to indicate when an operation is complete. the system is backwards compatible with older external interfaces. 6.1.1 features single-wire communication with host development system bdmv4 (and bdm2): enhanced capability for allowing more ?xibility in clock rates bdmv4: sync command to determine communication rate bdmv4: go_until command bdmv4: hardware handshake protocol to increase the performance of the serial communication active out of reset in special single-chip mode enbdm sdv 16-bit shift register bkgd clocks data address host system bus interface and control logic instruction decode and execution standard bdm firmware lookup table clksw bdmact entag trace
chapter 6 background debug module (bdmv4) block description 166 mc9s12q128 freescale semiconductor rev 1.09 nine hardware commands using free cycles, if available, for minimal cpu intervention hardware commands not requiring active bdm 15 ?mware commands execute from the standard bdm ?mware lookup table instruction tagging capability software control of bdm operation during wait mode software selectable clocks when secured, hardware commands are allowed to access the register space in special single-chip mode, if the flash and eeprom erase tests fail. 6.1.2 modes of operation bdm is available in all operating modes but must be enabled before ?mware commands are executed. some system peripherals may have a control bit which allows suspending the peripheral function during background debug mode. 6.1.2.1 regular run modes all of these operations refer to the part in run mode. the bdm does not provide controls to conserve power during run mode. normal operation general operation of the bdm is available and operates the same in all normal modes. special single-chip mode in special single-chip mode, background operation is enabled and active out of reset. this allows programming a system with blank memory. special peripheral mode bdm is enabled and active immediately out of reset. bdm can be disabled by clearing the bdmact bit in the bdm status (bdmsts) register. the bdm serial system should not be used in special peripheral mode. note the bdm serial system should not be used in special peripheral mode since the cpu, which in other modes interfaces with the bdm to relinquish control of the bus during a free cycle or a steal operation, is not operating in this mode. emulation modes general operation of the bdm is available and operates the same as in normal modes. 6.1.2.2 secure mode operation if the part is in secure mode, the operation of the bdm is reduced to a small subset of its regular run mode operation. secure operation prevents access to flash or eeprom other than allowing erasure.
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 167 rev 1.09 6.2 external signal description a single-wire interface pin is used to communicate with the bdm system. two additional pins are used for instruction tagging. these pins are part of the multiplexed external bus interface (mebi) sub-block and all interfacing between the mebi and bdm is done within the core interface boundary. functional descriptions of the pins are provided below for completeness. bkgd ?background interface pin t a ghi ?high byte instruction tagging pin t a glo ?low byte instruction tagging pin bkgd and t a ghi share the same pin. t a glo and lstrb share the same pin. note generally these pins are shared as described, but it is best to check the device overview chapter to make certain. all mcus at the time of this writing have followed this pin sharing scheme. 6.2.1 bkgd ?background interface pin debugging control logic communicates with external devices serially via the single-wire background interface pin (bkgd). during reset, this pin is a mode select input which selects between normal and special modes of operation. after reset, this pin becomes the dedicated serial interface pin for the background debug mode. 6.2.2 t a ghi ?high byte instruction tagging pin this pin is used to tag the high byte of an instruction. when instruction tagging is on, a logic 0 at the falling edge of the external clock (eclk) tags the high half of the instruction word being read into the instruction queue. 6.2.3 t a glo ?low byte instruction tagging pin this pin is used to tag the low byte of an instruction. when instruction tagging is on and low strobe is enabled, a logic 0 at the falling edge of the external clock (eclk) tags the low half of the instruction word being read into the instruction queue.
chapter 6 background debug module (bdmv4) block description 168 mc9s12q128 freescale semiconductor rev 1.09 6.3 memory map and register de?ition a summary of the registers associated with the bdm is shown in figure 6-2 . registers are accessed by host-driven communications to the bdm hardware using read_bd and write_bd commands. detailed descriptions of the registers and associated bits are given in the subsections that follow. 6.3.1 module memory map table 6-1. int memory map register address use access 0xff00 reserved 0xff01 bdm status register (bdmsts) r/w 0xff02 0xff05 reserved 0xff06 bdm ccr holding register (bdmccr) r/w 0xff07 bdm internal register position (bdminr) r 0xff08 0xff0b reserved
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 169 rev 1.09 6.3.2 register descriptions register name bit 7 6 5 4321 bit 0 0xff00 reserved rxxxxxx0 0 w 0xff01 bdmsts r enbdm bdmact entag sdv trace clksw unsec 0 w 0xff02 reserved rxxxxxxxx w 0xff03 reserved rxxxxxxxx w 0xff04 reserved rxxxxxxxx w 0xff05 reserved rxxxxxxxx w 0xff06 bdmccr r ccr7 ccr6 ccr5 ccr4 ccr3 ccr2 ccr1 ccr0 w 0xff07 bdminr r 0 reg14 reg13 reg12 reg11 0 0 0 w 0xff08 reserved r00000000 w 0xff09 reserved r00000000 w 0xff0a reserved rxxxxxxxx w 0xff0b reserved rxxxxxxxx w = unimplemented, reserved = implemented (do not alter) x = indeterminate 0 = always read zero figure 6-2. bdm register summary
chapter 6 background debug module (bdmv4) block description 170 mc9s12q128 freescale semiconductor rev 1.09 6.3.2.1 bdm status register (bdmsts) read: all modes through bdm operation write: all modes but subject to the following: bdmact can only be set by bdm hardware upon entry into bdm. it can only be cleared by the standard bdm ?mware lookup table upon exit from bdm active mode. clksw can only be written via bdm hardware or standard bdm ?mware write commands. all other bits, while writable via bdm hardware or standard bdm ?mware write commands, should only be altered by the bdm hardware or standard ?mware lookup table as part of bdm command execution. enbdm should only be set via a bdm hardware command if the bdm ?mware commands are needed. (this does not apply in special single-chip mode). 0xff01 76543210 r enbdm bdmact entag sdv trace clksw unsec 0 w reset: special single-chip mode: special peripheral mode: all other modes: 1 (1) 0 0 0 1. enbdm is read as "1" by a debugging environment in special single-chip mode when the device is not secured or secured but fully erased (flash and eeprom).this is because the enbdm bit is set by the standard firmware before a bdm command can be fully transmitted and executed. 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (2) 0 0 0 2. unsec is read as "1" by a debugging environment in special single-chip mode when the device is secured and fully erased, else it is "0" and can only be read if not secure (see also bit description). 0 0 0 0 = unimplemented or reserved = implemented (do not alter) figure 6-3. bdm status register (bdmsts) note:
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 171 rev 1.09 table 6-2. bdmsts field descriptions field description 7 enbdm enable bdm ?this bit controls whether the bdm is enabled or disabled. when enabled, bdm can be made active to allow ?mware commands to be executed. when disabled, bdm cannot be made active but bdm hardware commands are allowed. 0 bdm disabled 1 bdm enabled note: enbdm is set by the ?mware immediately out of reset in special single-chip mode. in secure mode, this bit will not be set by the ?mware until after the eeprom and flash erase verify tests are complete. 6 bdmact bdm active status ?this bit becomes set upon entering bdm. the standard bdm ?mware lookup table is then enabled and put into the memory map. bdmact is cleared by a carefully timed store instruction in the standard bdm ?mware as part of the exit sequence to return to user code and remove the bdm memory from the map. 0 bdm not active 1 bdm active 5 entag tagging enable ?this bit indicates whether instruction tagging in enabled or disabled. it is set when the taggo command is executed and cleared when bdm is entered. the serial system is disabled and the tag function enabled 16 cycles after this bit is written. bdm cannot process serial commands while tagging is active. 0 tagging not enabled or bdm active 1 tagging enabled 4 sdv shift data valid this bit is set and cleared by the bdm hardware. it is set after data has been transmitted as part of a ?mware read command or after data has been received as part of a ?mware write command. it is cleared when the next bdm command has been received or bdm is exited. sdv is used by the standard bdm ?mware to control program ?w execution. 0 data phase of command not complete 1 data phase of command is complete 3 trace trace1 bdm firmware command is being executed ?this bit gets set when a bdm trace1 ?mware command is ?st recognized. it will stay set as long as continuous back-to-back trace1 commands are executed. this bit will get cleared when the next command that is not a trace1 command is recognized. 0 trace1 command is not being executed 1 trace1 command is being executed
chapter 6 background debug module (bdmv4) block description 172 mc9s12q128 freescale semiconductor rev 1.09 2 clksw clock switch the clksw bit controls which clock the bdm operates with. it is only writable from a hardware bdm command. a 150 cycle delay at the clock speed that is active during the data portion of the command will occur before the new clock source is guaranteed to be active. the start of the next bdm command uses the new clock for timing subsequent bdm communications. table 6-3 shows the resulting bdm clock source based on the clksw and the pllsel (pll select from the clock and reset generator) bits. note: the bdm alternate clock source can only be selected when clksw = 0 and pllsel = 1. the bdm serial interface is now fully synchronized to the alternate clock source, when enabled. this eliminates frequency restriction on the alternate clock which was required on previous versions. refer to the device overview section to determine which clock connects to the alternate clock source input. note: if the acknowledge function is turned on, changing the clksw bit will cause the ack to be at the new rate for the write command which changes it. 1 unsec unsecure this bit is only writable in special single-chip mode from the bdm secure ?mware and always gets reset to zero. it is in a zero state as secure mode is entered so that the secure bdm ?mware lookup table is enabled and put into the memory map along with the standard bdm ?mware lookup table. the secure bdm ?mware lookup table veri?s that the on-chip eeprom and flash eeprom are erased. this being the case, the unsec bit is set and the bdm program jumps to the start of the standard bdm ?mware lookup table and the secure bdm ?mware lookup table is turned off. if the erase test fails, the unsec bit will not be asserted. 0 system is in a secured mode 1 system is in a unsecured mode note: when unsec is set, security is off and the user can change the state of the secure bits in the on-chip flash eeprom. note that if the user does not change the state of the bits to ?nsecured?mode, the system will be secured again when it is next taken out of reset. table 6-3. bdm clock sources pllsel clksw bdmclk 0 0 bus clock 0 1 bus clock 1 0 alternate clock (refer to the device overview chapter to determine the alternate clock source) 1 1 bus clock dependent on the pll table 6-2. bdmsts field descriptions (continued) field description
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 173 rev 1.09 6.3.2.2 bdm ccr holding register (bdmccr) read: all modes write: all modes note when bdm is made active, the cpu stores the value of the ccr register in the bdmccr register. however, out of special single-chip reset, the bdmccr is set to 0xd8 and not 0xd0 which is the reset value of the ccr register. when entering background debug mode, the bdm ccr holding register is used to save the contents of the condition code register of the users program. it is also used for temporary storage in the standard bdm ?mware mode. the bdm ccr holding register can be written to modify the ccr value. 6.3.2.3 bdm internal register position register (bdminr) read: all modes write: never 0xff06 76543210 r ccr7 ccr6 ccr5 ccr4 ccr3 ccr2 ccr1 ccr0 w reset 0 0 0 00000 figure 6-4. bdm ccr holding register (bdmccr) 0xff07 76543210 r 0 reg14 reg13 reg12 reg11 0 0 0 w reset 0 0 0 00000 = unimplemented or reserved figure 6-5. bdm internal register position (bdminr) table 6-4. bdminr field descriptions field description 6:3 reg[14:11] internal register map position these four bits show the state of the upper ?e bits of the base address for the systems relocatable register block. bdminr is a shadow of the initrg register which maps the register block to any 2k byte space within the ?st 32k bytes of the 64k byte address space.
chapter 6 background debug module (bdmv4) block description 174 mc9s12q128 freescale semiconductor rev 1.09 6.4 functional description the bdm receives and executes commands from a host via a single wire serial interface. there are two types of bdm commands, namely, hardware commands and ?mware commands. hardware commands are used to read and write target system memory locations and to enter active background debug mode, see section 6.4.3, ?dm hardware commands . target system memory includes all memory that is accessible by the cpu. firmware commands are used to read and write cpu resources and to exit from active background debug mode, see section 6.4.4, ?tandard bdm firmware commands . the cpu resources referred to are the accumulator (d), x index register (x), y index register (y), stack pointer (sp), and program counter (pc). hardware commands can be executed at any time and in any mode excluding a few exceptions as highlighted, see section 6.4.3, ?dm hardware commands . firmware commands can only be executed when the system is in active background debug mode (bdm). 6.4.1 security if the user resets into special single-chip mode with the system secured, a secured mode bdm ?mware lookup table is brought into the map overlapping a portion of the standard bdm ?mware lookup table. the secure bdm ?mware veri?s that the on-chip eeprom and flash eeprom are erased. this being the case, the unsec bit will get set. the bdm program jumps to the start of the standard bdm ?mware and the secured mode bdm ?mware is turned off and all bdm commands are allowed. if the eeprom or flash do not verify as erased, the bdm ?mware sets the enbdm bit, without asserting unsec, and the ?mware enters a loop. this causes the bdm hardware commands to become enabled, but does not enable the ?mware commands. this allows the bdm hardware to be used to erase the eeprom and flash. after execution of the secure ?mware, regardless of the results of the erase tests, the cpu registers, initee and ppage, will no longer be in their reset state. 6.4.2 enabling and activating bdm the system must be in active bdm to execute standard bdm ?mware commands. bdm can be activated only after being enabled. bdm is enabled by setting the enbdm bit in the bdm status (bdmsts) register. the enbdm bit is set by writing to the bdm status (bdmsts) register, via the single-wire interface, using a hardware command such as write_bd_byte. after being enabled, bdm is activated by one of the following 1 : hardware background command bdm external instruction tagging mechanism cpu bgnd instruction breakpoint sub-blocks force or tag mechanism 2 when bdm is activated, the cpu ?ishes executing the current instruction and then begins executing the ?mware in the standard bdm ?mware lookup table. when bdm is activated by the breakpoint sub- 1. bdm is enabled and active immediately out of special single-chip reset. 2. this method is only available on systems that have a a breakpoint or a debug sub-block.
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 175 rev 1.09 block, the type of breakpoint used determines if bdm becomes active before or after execution of the next instruction. note if an attempt is made to activate bdm before being enabled, the cpu resumes normal instruction execution after a brief delay. if bdm is not enabled, any hardware background commands issued are ignored by the bdm and the cpu is not delayed. in active bdm, the bdm registers and standard bdm ?mware lookup table are mapped to addresses 0xff00 to 0xffff. bdm registers are mapped to addresses 0xff00 to 0xff07. the bdm uses these registers which are readable anytime by the bdm. however, these registers are not readable by user programs. 6.4.3 bdm hardware commands hardware commands are used to read and write target system memory locations and to enter active background debug mode. target system memory includes all memory that is accessible by the cpu such as on-chip ram, eeprom, flash eeprom, i/o and control registers, and all external memory. hardware commands are executed with minimal or no cpu intervention and do not require the system to be in active bdm for execution, although they can continue to be executed in this mode. when executing a hardware command, the bdm sub-block waits for a free cpu bus cycle so that the background access does not disturb the running application program. if a free cycle is not found within 128 clock cycles, the cpu is momentarily frozen so that the bdm can steal a cycle. when the bdm ?ds a free cycle, the operation does not intrude on normal cpu operation provided that it can be completed in a single cycle. however, if an operation requires multiple cycles the cpu is frozen until the operation is complete, even though the bdm found a free cycle.
chapter 6 background debug module (bdmv4) block description 176 mc9s12q128 freescale semiconductor rev 1.09 the bdm hardware commands are listed in table 6-5 . note: if enabled, ack will occur when data is ready for transmission for all bdm read commands and will occur after the write is complete for all bdm write commands. the read_bd and write_bd commands allow access to the bdm register locations. these locations are not normally in the system memory map but share addresses with the application in memory. to distinguish between physical memory locations that share the same address, bdm memory resources are enabled just for the read_bd and write_bd access cycle. this allows the bdm to access bdm locations unobtrusively, even if the addresses con?ct with the application memory map. 6.4.4 standard bdm firmware commands firmware commands are used to access and manipulate cpu resources. the system must be in active bdm to execute standard bdm ?mware commands, see section 6.4.2, ?nabling and activating bdm . normal instruction execution is suspended while the cpu executes the ?mware located in the standard bdm ?mware lookup table. the hardware command background is the usual way to activate bdm. as the system enters active bdm, the standard bdm ?mware lookup table and bdm registers become visible in the on-chip memory map at 0xff00?xffff, and the cpu begins executing the standard bdm table 6-5. hardware commands command opcode (hex) data description background 90 none enter background mode if ?mware is enabled. if enabled, an ack will be issued when the part enters active background mode. ack_enable d5 none enable handshake. issues an ack pulse after the command is executed. ack_disable d6 none disable handshake. this command does not issue an ack pulse. read_bd_byte e4 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table in map. odd address data on low byte; even address data on high byte. read_bd_word ec 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table in map. must be aligned access. read_byte e0 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table out of map. odd address data on low byte; even address data on high byte. read_word e8 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table out of map. must be aligned access. write_bd_byte c4 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table in map. odd address data on low byte; even address data on high byte. write_bd_word cc 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table in map. must be aligned access. write_byte c0 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table out of map. odd address data on low byte; even address data on high byte. write_word c8 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table out of map. must be aligned access.
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 177 rev 1.09 ?mware. the standard bdm ?mware watches for serial commands and executes them as they are received. the ?mware commands are shown in table 6-6 . 6.4.5 bdm command structure hardware and ?mware bdm commands start with an 8-bit opcode followed by a 16-bit address and/or a 16-bit data word depending on the command. all the read commands return 16 bits of data despite the byte or word implication in the command name. note 8-bit reads return 16-bits of data, of which, only one byte will contain valid data. if reading an even address, the valid data will appear in the msb. if reading an odd address, the valid data will appear in the lsb. table 6-6. firmware commands command (1) 1. if enabled, ack will occur when data is ready for transmission for all bdm read commands and will occur after the write is complete for all bdm write commands. opcode (hex) data description read_next 62 16-bit data out increment x by 2 (x = x + 2), then read word x points to. read_pc 63 16-bit data out read program counter. read_d 64 16-bit data out read d accumulator. read_x 65 16-bit data out read x index register. read_y 66 16-bit data out read y index register. read_sp 67 16-bit data out read stack pointer. write_next 42 16-bit data in increment x by 2 (x = x + 2), then write word to location pointed to by x. write_pc 43 16-bit data in write program counter. write_d 44 16-bit data in write d accumulator. write_x 45 16-bit data in write x index register. write_y 46 16-bit data in write y index register. write_sp 47 16-bit data in write stack pointer. go 08 none go to user program. if enabled, ack will occur when leaving active background mode. go_until (2) 2. both wait (with clocks to the s12 cpu core disabled) and stop disable the ack function. the go_until command will not get an acknowledge if one of these two cpu instructions occurs before the ?ntil instruction. this can be a problem for any instruction that uses ack, but go_until is a lot more dif?ult for the development tool to time-out. 0c none go to user program. if enabled, ack will occur upon returning to active background mode. trace1 10 none execute one user instruction then return to active bdm. if enabled, ack will occur upon returning to active background mode. taggo 18 none enable tagging and go to user program. there is no ack pulse related to this command.
chapter 6 background debug module (bdmv4) block description 178 mc9s12q128 freescale semiconductor rev 1.09 note 16-bit misaligned reads and writes are not allowed. if attempted, the bdm will ignore the least signi?ant bit of the address and will assume an even address from the remaining bits. for hardware data read commands, the external host must wait 150 bus clock cycles after sending the address before attempting to obtain the read data. this is to be certain that valid data is available in the bdm shift register, ready to be shifted out. for hardware write commands, the external host must wait 150 bus clock cycles after sending the data to be written before attempting to send a new command. this is to avoid disturbing the bdm shift register before the write has been completed. the 150 bus clock cycle delay in both cases includes the maximum 128 cycle delay that can be incurred as the bdm waits for a free cycle before stealing a cycle. for ?mware read commands, the external host should wait 44 bus clock cycles after sending the command opcode and before attempting to obtain the read data. this includes the potential of an extra 7 cycles when the access is external with a narrow bus access (+1 cycle) and / or a stretch (+1, 2, or 3 cycles), (7 cycles could be needed if both occur). the 44 cycle wait allows enough time for the requested data to be made available in the bdm shift register, ready to be shifted out. note this timing has increased from previous bdm modules due to the new capability in which the bdm serial interface can potentially run faster than the bus. on previous bdm modules this extra time could be hidden within the serial time. for ?mware write commands, the external host must wait 32 bus clock cycles after sending the data to be written before attempting to send a new command. this is to avoid disturbing the bdm shift register before the write has been completed. the external host should wait 64 bus clock cycles after a trace1 or go command before starting any new serial command. this is to allow the cpu to exit gracefully from the standard bdm ?mware lookup table and resume execution of the user code. disturbing the bdm shift register prematurely may adversely affect the exit from the standard bdm ?mware lookup table. note if the bus rate of the target processor is unknown or could be changing, it is recommended that the ack (acknowledge function) be used to indicate when an operation is complete. when using ack, the delay times are automated. figure 6-6 represents the bdm command structure. the command blocks illustrate a series of eight bit times starting with a falling edge. the bar across the top of the blocks indicates that the bkgd line idles in the high state. the time for an 8-bit command is 8 16 target clock cycles. 1 1. target clock cycles are cycles measured using the target mcus serial clock rate. see section 6.4.6, ?dm serial interface , and section 6.3.2.1, ?dm status register (bdmsts) , for information on how serial clock rate is selected.
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 179 rev 1.09 figure 6-6. bdm command structure 6.4.6 bdm serial interface the bdm communicates with external devices serially via the bkgd pin. during reset, this pin is a mode select input which selects between normal and special modes of operation. after reset, this pin becomes the dedicated serial interface pin for the bdm. the bdm serial interface is timed using the clock selected by the clksw bit in the status register see section 6.3.2.1, ?dm status register (bdmsts) . this clock will be referred to as the target clock in the following explanation. the bdm serial interface uses a clocking scheme in which the external host generates a falling edge on the bkgd pin to indicate the start of each bit time. this falling edge is sent for every bit whether data is transmitted or received. data is transferred most signi?ant bit (msb) ?st at 16 target clock cycles per bit. the interface times out if 512 clock cycles occur between falling edges from the host. the bkgd pin is a pseudo open-drain pin and has an weak on-chip active pull-up that is enabled at all times. it is assumed that there is an external pull-up and that drivers connected to bkgd do not typically drive the high level. because r-c rise time could be unacceptably long, the target system and host provide brief driven-high (speedup) pulses to drive bkgd to a logic 1. the source of this speedup pulse is the host for transmit cases and the target for receive cases. the timing for host-to-target is shown in figure 6-7 and that of target-to-host in figure 6-8 and figure 6- 9 . all four cases begin when the host drives the bkgd pin low to generate a falling edge. because the host and target are operating from separate clocks, it can take the target system up to one full clock cycle to recognize this edge. the target measures delays from this perceived start of the bit time while the host measures delays from the point it actually drove bkgd low to start the bit up to one target clock cycle hardware hardware firmware firmware go, 44-bc bc = bus clock cycles command address 150-bc delay next delay 8 bits at 16 tc/bit 16 bits at 16 tc/bit 16 bits at 16 tc/bit command address data next data read write read write trace command next command data 64-bc delay next command 150-bc delay 32-bc delay command command command command data next command tc = target clock cycles
chapter 6 background debug module (bdmv4) block description 180 mc9s12q128 freescale semiconductor rev 1.09 earlier. synchronization between the host and target is established in this manner at the start of every bit time. figure 6-7 shows an external host transmitting a logic 1 and transmitting a logic 0 to the bkgd pin of a target system. the host is asynchronous to the target, so there is up to a one clock-cycle delay from the host-generated falling edge to where the target recognizes this edge as the beginning of the bit time. ten target clock cycles later, the target senses the bit level on the bkgd pin. internal glitch detect logic requires the pin be driven high no later that eight target clock cycles after the falling edge for a logic 1 transmission. because the host drives the high speedup pulses in these two cases, the rising edges look like digitally driven signals. figure 6-7. bdm host-to-target serial bit timing the receive cases are more complicated. figure 6-8 shows the host receiving a logic 1 from the target system. because the host is asynchronous to the target, there is up to one clock-cycle delay from the host- generated falling edge on bkgd to the perceived start of the bit time in the target. the host holds the bkgd pin low long enough for the target to recognize it (at least two target clock cycles). the host must release the low drive before the target drives a brief high speedup pulse seven target clock cycles after the perceived start of the bit time. the host should sample the bit level about 10 target clock cycles after it started the bit time. earliest start of next bit target senses bit 10 cycles synchronization uncertainty clock target system host transmit 1 host transmit 0 perceived s tart of bit time
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 181 rev 1.09 figure 6-8. bdm target-to-host serial bit timing (logic 1) figure 6-9 shows the host receiving a logic 0 from the target. because the host is asynchronous to the target, there is up to a one clock-cycle delay from the host-generated falling edge on bkgd to the start of the bit time as perceived by the target. the host initiates the bit time but the target ?ishes it. because the target wants the host to receive a logic 0, it drives the bkgd pin low for 13 target clock cycles then brie? drives it high to speed up the rising edge. the host samples the bit level about 10 target clock cycles after starting the bit time. figure 6-9. bdm target-to-host serial bit timing (logic 0) high-impedance earliest start of next bit r-c rise 10 cycles 10 cycles host samples bkgd pin perceived start of bit time bkgd pin clock target system host drive to bkgd pin target system speedup pulse high-impedance high-impedance earliest start of next bit clock target sys. host drive to bkgd pin bkgd pin perceived start of bit time 10 cycles 10 cycles host samples bkgd pin target sys. drive and speedup pulse speedup pulse high-impedance
chapter 6 background debug module (bdmv4) block description 182 mc9s12q128 freescale semiconductor rev 1.09 6.4.7 serial interface hardware handshake protocol bdm commands that require cpu execution are ultimately treated at the mcu bus rate. because the bdm clock source can be asynchronously related to the bus frequency, when clksw = 0, it is very helpful to provide a handshake protocol in which the host could determine when an issued command is executed by the cpu. the alternative is to always wait the amount of time equal to the appropriate number of cycles at the slowest possible rate the clock could be running. this sub-section will describe the hardware handshake protocol. the hardware handshake protocol signals to the host controller when an issued command was successfully executed by the target. this protocol is implemented by a 16 serial clock cycle low pulse followed by a brief speedup pulse in the bkgd pin. this pulse is generated by the target mcu when a command, issued by the host, has been successfully executed (see figure 6-10 ). this pulse is referred to as the ack pulse. after the ack pulse has ?ished: the host can start the bit retrieval if the last issued command was a read command, or start a new command if the last command was a write command or a control command (background, go, go_until, or trace1). the ack pulse is not issued earlier than 32 serial clock cycles after the bdm command was issued. the end of the bdm command is assumed to be the 16th tick of the last bit. this minimum delay assures enough time for the host to perceive the ack pulse. note also that, there is no upper limit for the delay between the command and the related ack pulse, because the command execution depends upon the cpu bus frequency, which in some cases could be very slow compared to the serial communication rate. this protocol allows a great ?xibility for the pod designers, because it does not rely on any accurate time measurement or short response time to any event in the serial communication. figure 6-10. target acknowledge pulse (ack) note if the ack pulse was issued by the target, the host assumes the previous command was executed. if the cpu enters wait or stop prior to executing a hardware command, the ack pulse will not be issued meaning that the bdm command was not executed. after entering wait or stop mode, the bdm command is no longer pending. 16 cycles bdm clock (target mcu) target transmits pulse ack high-impedance bkgd pin minimum delay from the bdm command 32 cycles earliest start of next bit speedup pulse 16th tick of the last commad bit high-impedance
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 183 rev 1.09 figure 6-11 shows the ack handshake protocol in a command level timing diagram. the read_byte instruction is used as an example. first, the 8-bit instruction opcode is sent by the host, followed by the address of the memory location to be read. the target bdm decodes the instruction. a bus cycle is grabbed (free or stolen) by the bdm and it executes the read_byte operation. having retrieved the data, the bdm issues an ack pulse to the host controller, indicating that the addressed byte is ready to be retrieved. after detecting the ack pulse, the host initiates the byte retrieval process. note that data is sent in the form of a word and the host needs to determine which is the appropriate byte based on whether the address was odd or even. figure 6-11. handshake protocol at command level differently from the normal bit transfer (where the host initiates the transmission), the serial interface ack handshake pulse is initiated by the target mcu by issuing a falling edge in the bkgd pin. the hardware handshake protocol in figure 6-10 speci?s the timing when the bkgd pin is being driven, so the host should follow this timing constraint in order to avoid the risk of an electrical con?ct in the bkgd pin. note the only place the bkgd pin can have an electrical con?ct is when one side is driving low and the other side is issuing a speedup pulse (high). other ?ighs are pulled rather than driven. however, at low rates the time of the speedup pulse can become lengthy and so the potential con?ct time becomes longer as well. the ack handshake protocol does not support nested ack pulses. if a bdm command is not acknowledge by an ack pulse, the host needs to abort the pending command ?st in order to be able to issue a new bdm command. when the cpu enters wait or stop while the host issues a command that requires cpu execution (e.g., write_byte), the target discards the incoming command due to the wait or stop being detected. therefore, the command is not acknowledged by the target, which means that the ack pulse will not be issued in this case. after a certain time the host should decide to abort the ack sequence in order to be free to issue a new command. therefore, the protocol should provide a mechanism in which a command, and therefore a pending ack, could be aborted. note differently from a regular bdm command, the ack pulse does not provide a time out. this means that in the case of a wait or stop instruction being executed, the ack would be prevented from being issued. if not aborted, the ack would remain pending inde?itely. see the handshake abort procedure described in section 6.4.8, ?ardware handshake abort procedure . read_byte bdm issues the bkgd pin byte address bdm executes the read_byte command host target host target bdm decodes the command ack pulse (out of scale) host target (2) bytes are retrieved new bdm command
chapter 6 background debug module (bdmv4) block description 184 mc9s12q128 freescale semiconductor rev 1.09 6.4.8 hardware handshake abort procedure the abort procedure is based on the sync command. in order to abort a command, which had not issued the corresponding ack pulse, the host controller should generate a low pulse in the bkgd pin by driving it low for at least 128 serial clock cycles and then driving it high for one serial clock cycle, providing a speedup pulse. by detecting this long low pulse in the bkgd pin, the target executes the sync protocol, see section 6.4.9, ?ync ?request timed reference pulse , and assumes that the pending command and therefore the related ack pulse, are being aborted. therefore, after the sync protocol has been completed the host is free to issue new bdm commands. although it is not recommended, the host could abort a pending bdm command by issuing a low pulse in the bkgd pin shorter than 128 serial clock cycles, which will not be interpreted as the sync command. the ack is actually aborted when a falling edge is perceived by the target in the bkgd pin. the short abort pulse should have at least 4 clock cycles keeping the bkgd pin low, in order to allow the falling edge to be detected by the target. in this case, the target will not execute the sync protocol but the pending command will be aborted along with the ack pulse. the potential problem with this abort procedure is when there is a con?ct between the ack pulse and the short abort pulse. in this case, the target may not perceive the abort pulse. the worst case is when the pending command is a read command (i.e., read_byte). if the abort pulse is not perceived by the target the host will attempt to send a new command after the abort pulse was issued, while the target expects the host to retrieve the accessed memory byte. in this case, host and target will run out of synchronism. however, if the command to be aborted is not a read command the short abort pulse could be used. after a command is aborted the target assumes the next falling edge, after the abort pulse, is the ?st bit of a new bdm command. note the details about the short abort pulse are being provided only as a reference for the reader to better understand the bdm internal behavior. it is not recommended that this procedure be used in a real application. because the host knows the target serial clock frequency, the sync command (used to abort a command) does not need to consider the lower possible target frequency. in this case, the host could issue a sync very close to the 128 serial clock cycles length. providing a small overhead on the pulse length in order to assure the sync pulse will not be misinterpreted by the target. see section 6.4.9, ?ync ?request timed reference pulse . figure 6-12 shows a sync command being issued after a read_byte, which aborts the read_byte command. note that, after the command is aborted a new command could be issued by the host computer. note figure 6-12 does not represent the signals in a true timing scale
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 185 rev 1.09 figure 6-12. ack abort procedure at the command level figure 6-13 shows a con?ct between the ack pulse and the sync request pulse. this con?ct could occur if a pod device is connected to the target bkgd pin and the target is already in debug active mode. consider that the target cpu is executing a pending bdm command at the exact moment the pod is being connected to the bkgd pin. in this case, an ack pulse is issued along with the sync command. in this case, there is an electrical con?ct between the ack speedup pulse and the sync pulse. because this is not a probable situation, the protocol does not prevent this con?ct from happening. figure 6-13. ack pulse and sync request con?ct note this information is being provided so that the mcu integrator will be aware that such a con?ct could eventually occur. the hardware handshake protocol is enabled by the ack_enable and disabled by the ack_disable bdm commands. this provides backwards compatibility with the existing pod devices which are not able to execute the hardware handshake protocol. it also allows for new pod devices, that support the hardware handshake protocol, to freely communicate with the target device. if desired, without the need for waiting for the ack pulse. read_byte read_status bkgd pin memory address new bdm command new bdm command host target host target host target sync response from the target (out of scale) bdm decode and starts to executes the read_byte cmd read_byte cmd is aborted by the sync request (out of scale) bdm clock (target mcu) target mcu drives to bkgd pin bkgd pin 16 cycles speedup pulse high-impedance host drives sync to bkgd pin ack pulse host sync request pulse at least 128 cycles electrical conflict host and target drive to bkgd pin
chapter 6 background debug module (bdmv4) block description 186 mc9s12q128 freescale semiconductor rev 1.09 the commands are described as follows: ack_enable enables the hardware handshake protocol. the target will issue the ack pulse when a cpu command is executed by the cpu. the ack_enable command itself also has the ack pulse as a response. ack_disable disables the ack pulse protocol. in this case, the host needs to use the worst case delay time at the appropriate places in the protocol. the default state of the bdm after reset is hardware handshake protocol disabled. all the read commands will ack (if enabled) when the data bus cycle has completed and the data is then ready for reading out by the bkgd serial pin. all the write commands will ack (if enabled) after the data has been received by the bdm through the bkgd serial pin and when the data bus cycle is complete. see section 6.4.3, ?dm hardware commands , and section 6.4.4, ?tandard bdm firmware commands , for more information on the bdm commands. the ack_enable sends an ack pulse when the command has been completed. this feature could be used by the host to evaluate if the target supports the hardware handshake protocol. if an ack pulse is issued in response to this command, the host knows that the target supports the hardware handshake protocol. if the target does not support the hardware handshake protocol the ack pulse is not issued. in this case, the ack_enable command is ignored by the target because it is not recognized as a valid command. the background command will issue an ack pulse when the cpu changes from normal to background mode. the ack pulse related to this command could be aborted using the sync command. the go command will issue an ack pulse when the cpu exits from background mode. the ack pulse related to this command could be aborted using the sync command. the go_until command is equivalent to a go command with exception that the ack pulse, in this case, is issued when the cpu enters into background mode. this command is an alternative to the go command and should be used when the host wants to trace if a breakpoint match occurs and causes the cpu to enter active background mode. note that the ack is issued whenever the cpu enters bdm, which could be caused by a breakpoint match or by a bgnd instruction being executed. the ack pulse related to this command could be aborted using the sync command. the trace1 command has the related ack pulse issued when the cpu enters background active mode after one instruction of the application program is executed. the ack pulse related to this command could be aborted using the sync command. the taggo command will not issue an ack pulse because this would interfere with the tagging function shared on the same pin.
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 187 rev 1.09 6.4.9 sync ?request timed reference pulse the sync command is unlike other bdm commands because the host does not necessarily know the correct communication speed to use for bdm communications until after it has analyzed the response to the sync command. to issue a sync command, the host should perform the following steps: 1. drive the bkgd pin low for at least 128 cycles at the lowest possible bdm serial communication frequency (the lowest serial communication frequency is determined by the crystal oscillator or the clock chosen by clksw.) 2. drive bkgd high for a brief speedup pulse to get a fast rise time (this speedup pulse is typically one cycle of the host clock.) 3. remove all drive to the bkgd pin so it reverts to high impedance. 4. listen to the bkgd pin for the sync response pulse. upon detecting the sync request from the host, the target performs the following steps: 1. discards any incomplete command received or bit retrieved. 2. waits for bkgd to return to a logic 1. 3. delays 16 cycles to allow the host to stop driving the high speedup pulse. 4. drives bkgd low for 128 cycles at the current bdm serial communication frequency. 5. drives a one-cycle high speedup pulse to force a fast rise time on bkgd. 6. removes all drive to the bkgd pin so it reverts to high impedance. the host measures the low time of this 128 cycle sync response pulse and determines the correct speed for subsequent bdm communications. typically, the host can determine the correct communication speed within a few percent of the actual target speed and the communication protocol can easily tolerate speed errors of several percent. as soon as the sync request is detected by the target, any partially received command or bit retrieved is discarded. this is referred to as a soft-reset, equivalent to a time-out in the serial communication. after the sync response, the target will consider the next falling edge (issued by the host) as the start of a new bdm command or the start of new sync request. another use of the sync command pulse is to abort a pending ack pulse. the behavior is exactly the same as in a regular sync command. note that one of the possible causes for a command to not be acknowledged by the target is a host-target synchronization problem. in this case, the command may not have been understood by the target and so an ack response pulse will not be issued. 6.4.10 instruction tracing when a trace1 command is issued to the bdm in active bdm, the cpu exits the standard bdm ?mware and executes a single instruction in the user code. as soon as this has occurred, the cpu is forced to return to the standard bdm ?mware and the bdm is active and ready to receive a new command. if the trace1 command is issued again, the next user instruction will be executed. this facilitates stepping or tracing through the user code one instruction at a time.
chapter 6 background debug module (bdmv4) block description 188 mc9s12q128 freescale semiconductor rev 1.09 if an interrupt is pending when a trace1 command is issued, the interrupt stacking operation occurs but no user instruction is executed. upon return to standard bdm ?mware execution, the program counter points to the ?st instruction in the interrupt service routine. 6.4.11 instruction tagging the instruction queue and cycle-by-cycle cpu activity are reconstructible in real time or from trace history that is captured by a logic analyzer. however, the reconstructed queue cannot be used to stop the cpu at a speci? instruction. this is because execution already has begun by the time an operation is visible outside the system. a separate instruction tagging mechanism is provided for this purpose. the tag follows program information as it advances through the instruction queue. when a tagged instruction reaches the head of the queue, the cpu enters active bdm rather than executing the instruction. note tagging is disabled when bdm becomes active and bdm serial commands are not processed while tagging is active. executing the bdm taggo command con?ures two system pins for tagging. the t a glo signal shares a pin with the lstrb signal, and the t a ghi signal shares a pin with the bkgd signal. table 6-7 shows the functions of the two tagging pins. the pins operate independently, that is the state of one pin does not affect the function of the other. the presence of logic level 0 on either pin at the fall of the external clock (eclk) performs the indicated function. high tagging is allowed in all modes. low tagging is allowed only when low strobe is enabled (lstrb is allowed only in wide expanded modes and emulation expanded narrow mode). 6.4.12 serial communication time-out the host initiates a host-to-target serial transmission by generating a falling edge on the bkgd pin. if bkgd is kept low for more than 128 target clock cycles, the target understands that a sync command was issued. in this case, the target will keep waiting for a rising edge on bkgd in order to answer the sync request pulse. if the rising edge is not detected, the target will keep waiting forever without any time-out limit. consider now the case where the host returns bkgd to logic one before 128 cycles. this is interpreted as a valid bit transmission, and not as a sync request. the target will keep waiting for another falling edge marking the start of a new bit. if, however, a new falling edge is not detected by the target within 512 clock cycles since the last falling edge, a time-out occurs and the current command is discarded without affecting memory or the operating mode of the mcu. this is referred to as a soft-reset. table 6-7. tag pin function t a ghi t a glo tag 1 1 no tag 1 0 low byte 0 1 high byte 0 0 both bytes
chapter 6 background debug module (bdmv4) block description freescale semiconductor mc9s12q128 189 rev 1.09 if a read command is issued but the data is not retrieved within 512 serial clock cycles, a soft-reset will occur causing the command to be disregarded. the data is not available for retrieval after the time-out has occurred. this is the expected behavior if the handshake protocol is not enabled. however, consider the behavior where the bdc is running in a frequency much greater than the cpu frequency. in this case, the command could time out before the data is ready to be retrieved. in order to allow the data to be retrieved even with a large clock frequency mismatch (between bdc and cpu) when the hardware handshake protocol is enabled, the time out between a read command and the data retrieval is disabled. therefore, the host could wait for more then 512 serial clock cycles and continue to be able to retrieve the data from an issued read command. however, as soon as the handshake pulse (ack pulse) is issued, the time-out feature is re-activated, meaning that the target will time out after 512 clock cycles. therefore, the host needs to retrieve the data within a 512 serial clock cycles time frame after the ack pulse had been issued. after that period, the read command is discarded and the data is no longer available for retrieval. any falling edge of the bkgd pin after the time-out period is considered to be a new command or a sync request. note that whenever a partially issued command, or partially retrieved data, has occurred the time out in the serial communication is active. this means that if a time frame higher than 512 serial clock cycles is observed between two consecutive negative edges and the command being issued or data being retrieved is not complete, a soft-reset will occur causing the partially received command or data retrieved to be disregarded. the next falling edge of the bkgd pin, after a soft-reset has occurred, is considered by the target as the start of a new bdm command, or the start of a sync request pulse. 6.4.13 operation in wait mode the bdm cannot be used in wait mode if the system disables the clocks to the bdm. there is a clearing mechanism associated with the wait instruction when the clocks to the bdm (cpu core platform) are disabled. as the clocks restart from wait mode, the bdm receives a soft reset (clearing any command in progress) and the ack function will be disabled. this is a change from previous bdm modules. 6.4.14 operation in stop mode the bdm is completely shutdown in stop mode. there is a clearing mechanism associated with the stop instruction. stop must be enabled and the part must go into stop mode for this to occur. as the clocks restart from stop mode, the bdm receives a soft reset (clearing any command in progress) and the ack function will be disabled. this is a change from previous bdm modules.
chapter 6 background debug module (bdmv4) block description 190 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 191 rev 1.09 chapter 7 debug module (dbgv1) block description 7.1 introduction this section describes the functionality of the debug (dbg) sub-block of the hcs12 core platform. the dbg module is designed to be fully compatible with the existing bkp_hcs12_a module (bkp mode) and furthermore provides an on-chip trace buffer with ?xible triggering capability (dbg mode). the dbg module provides for non-intrusive debug of application software. the dbg module is optimized for the hcs12 16-bit architecture. 7.1.1 features the dbg module in bkp mode includes these distinctive features: full or dual breakpoint mode compare on address and data (full) compare on either of two addresses (dual) bdm or swi breakpoint enter bdm on breakpoint (bdm) execute swi on breakpoint (swi) tagged or forced breakpoint break just before a speci? instruction will begin execution (tag) break on the ?st instruction boundary after a match occurs (force) single, range, or page address compares compare on address (single) compare on address 256 byte (range) compare on any 16k page (page) at forced breakpoints compare address on read or write high and/or low byte data compares comparator c can provide an additional tag or force breakpoint (enhancement for bkp mode)
chapter 7 debug module (dbgv1) block description 192 mc9s12q128 freescale semiconductor rev 1.09 the dbg in dbg mode includes these distinctive features: three comparators (a, b, and c) dual mode, comparators a and b used to compare addresses full mode, comparator a compares address and comparator b compares data can be used as trigger and/or breakpoint comparator c used in loop1 capture mode or as additional breakpoint four capture modes normal mode, change-of-?w information is captured based on trigger speci?ation loop1 mode, comparator c is dynamically updated to prevent redundant change-of-?w storage. detail mode, address and data for all cycles except program fetch (p) and free (f) cycles are stored in trace buffer pro?e mode, last instruction address executed by cpu is returned when trace buffer address is read two types of breakpoint or debug triggers break just before a speci? instruction will begin execution (tag) break on the ?st instruction boundary after a match occurs (force) bdm or swi breakpoint enter bdm on breakpoint (bdm) execute swi on breakpoint (swi) nine trigger modes for comparators a and b ? a or b a then b a and b, where b is data (full mode) a and not b, where b is data (full mode) event only b, store data a then event only b, store data inside range, a address b outside range, address < or address > b comparator c provides an additional tag or force breakpoint when capture mode is not con?ured in loop1 mode. sixty-four word (16 bits wide) trace buffer for storing change-of-?w information, event only data and other bus information. source address of taken conditional branches (long, short, bit-conditional, and loop constructs) destination address of indexed jmp, jsr, and call instruction. destination address of rti, rts, and rtc instructions vector address of interrupts, except for swi and bdm vectors
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 193 rev 1.09 data associated with event b trigger modes detail report mode stores address and data for all cycles except program (p) and free (f) cycles current instruction address when in pro?ing mode bgnd is not considered a change-of-?w (cof) by the debugger 7.1.2 modes of operation there are two main modes of operation: breakpoint mode and debug mode. each one is mutually exclusive of the other and selected via a software programmable control bit. in the breakpoint mode there are two sub-modes of operation: dual address mode, where a match on either of two addresses will cause the system to enter background debug mode (bdm) or initiate a software interrupt (swi). full breakpoint mode, where a match on address and data will cause the system to enter background debug mode (bdm) or initiate a software interrupt (swi). in debug mode, there are several sub-modes of operation. trigger modes there are many ways to create a logical trigger. the trigger can be used to capture bus information either starting from the trigger or ending at the trigger. types of triggers (a and b are registers): a only a or b a then b event only b (data capture) a then event only b (data capture) a and b, full mode a and not b, full mode inside range outside range capture modes there are several capture modes. these determine which bus information is saved and which is ignored. normal: save change-of-?w program fetches loop1: save change-of-?w program fetches, ignoring duplicates detail: save all bus operations except program and free cycles pro?e: poll target from external device 7.1.3 block diagram figure 7-1 is a block diagram of this module in breakpoint mode. figure 7-2 is a block diagram of this module in debug mode.
chapter 7 debug module (dbgv1) block description 194 mc9s12q128 freescale semiconductor rev 1.09 figure 7-1. dbg block diagram in bkp mode comparator compare block register block comparator comparator comparator comparator comparator expansion addresses expansion addresses address high address low data high data low address high address low comparator comparator read data high read data low . . . . . . . . . . . . clocks and bkp control control signals signals control block breakpoint modes and generation of swi, force bdm, and tags expansion address address write data read data read/write control control bits control signals results signals bkp0h bkp0l bkp0x bkpct0 bkp1x bkpct1 bkp1l bkp1h write bkp read data bus data bus data/address high mux data/address low mux
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 195 rev 1.09 figure 7-2. dbg block diagram in dbg mode 7.2 external signal description the dbg sub-module relies on the external bus interface (generally the mebi) when the dbg is matching on the external bus. the tag pins in table 7-1 (part of the mebi) may also be a part of the breakpoint operation. table 7-1. external system pins associated with dbg and mebi pin name pin functions description bkgd/modc/ t a ghi t a ghi when instruction tagging is on, a 0 at the falling edge of e tags the high half of the instruction word being read into the instruction queue. pe3/ lstrb/ t a glo t a glo in expanded wide mode or emulation narrow modes, when instruction tagging is on and low strobe is enabled, a 0 at the falling edge of e tags the low half of the instruction word being read into the instruction queue. tag force address bus match_a control read data bus read/write store mcu in bdm m u x pointer register match_b m u x event only write data bus trace buffer dbg read data bus dbg mode enable m u x write data bus read data bus read/write match_c loop1 detail m u x profile capture mode cpu program counter control comparator a address/data/control comparator b comparator c registers tracer buffer control logic change-of-flow indicators or profiling data 64 x 16 bit word trace buffer profile capture register last instruction address bus clock instruction last cycle
chapter 7 debug module (dbgv1) block description 196 mc9s12q128 freescale semiconductor rev 1.09 7.3 memory map and register de?ition a summary of the registers associated with the dbg sub-block is shown in figure 7-3 . detailed descriptions of the registers and bits are given in the subsections that follow. 7.3.1 module memory map 7.3.2 register descriptions this section consists of the dbg register descriptions in address order. most of the register bits can be written to in either bkp or dbg mode, although they may not have any effect in one of the modes. however, the only bits in the dbg module that can be written while the debugger is armed (arm = 1) are dbgen and arm table 7-2. dbgv1 memory map address offset use access 0x0020 debug control register (dbgc1) r/w 0x0021 debug status and control register (dbgsc) r/w 0x0022 debug trace buffer register high (dbgtbh) r 0x0023 debug trace buffer register low (dbgtbl) r 0x0024 debug count register (dbgcnt) r 0x0025 debug comparator c extended register (dbgccx) r/w 0x0026 debug comparator c register high (dbgcch) r/w 0x0027 debug comparator c register low (dbgccl) r/w 0x0028 debug control register 2 (dbgc2) / (bkpct0) r/w 0x0029 debug control register 3 (dbgc3) / (bkpct1) r/w 0x002a debug comparator a extended register (dbgcax) / (/bkp0x) r/w 0x002b debug comparator a register high (dbgcah) / (bkp0h) r/w 0x002c debug comparator a register low (dbgcal) / (bkp0l) r/w 0x002d debug comparator b extended register (dbgcbx) / (bkp1x) r/w 0x002e debug comparator b register high (dbgcbh) / (bkp1h) r/w 0x002f debug comparator b register low (dbgcbl) / (bkp1l) r/w name (1) bit 7 6 5 4 3 2 1 bit 0 0x0020 dbgc1 r dbgen arm trgsel begin dbgbrk 0 capmod w 0x0021 dbgsc raf bf cf 0 trg w = unimplemented or reserved figure 7-3. dbg register summary
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 197 rev 1.09 0x0022 dbgtbh r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w 0x0023 dbgtbl r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0024 dbgcnt r tbf 0 cnt w 0x0025 dbgccx ((2) ) r pagsel extcmp w 0x0026 dbgcch (2) r bit 15 14 13 12 11 10 9 bit 8 w 0x0027 dbgccl (2) r bit 7 6 5 4 3 2 1 bit 0 w 0x0028 dbgc2 bkpct0 r bkaben full bdm tagab bkcen tagc rwcen rwc w 0x0029 dbgc3 bkpct1 r bkambh bkambl bkbmbh bkbmbl rwaen rwa rwben rwb w 0x002a dbgcax bkp0x r pagsel extcmp w 0x002b dbgcah bkp0h r bit 15 14 13 12 11 10 9 bit 8 w 0x002c dbgcal bkp0l r bit 7 6 5 4 3 2 1 bit 0 w 0x002d dbgcbx bkp1x r pagsel extcmp w 0x002e dbgcbh bkp1h r bit 15 14 13 12 11 10 9 bit 8 w 0x002f dbgcbl bkp1l r bit 7 6 5 4 3 2 1 bit 0 w name (1) bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 7-3. dbg register summary (continued)
chapter 7 debug module (dbgv1) block description 198 mc9s12q128 freescale semiconductor rev 1.09 7.3.2.1 debug control register 1 (dbgc1) note all bits are used in dbg mode only. note this register cannot be written if bkp mode is enabled (bkaben in dbgc2 is set). 1. the dbg module is designed for backwards compatibility to existing bkp modules. register and bit names have changed from the bkp module. this column shows the dbg register name, as well as the bkp register name for reference. 2. comparator c can be used to enhance the bkp mode by providing a third breakpoint. module base + 0x0020 starting address location affected by initrg register setting. 76543210 r dbgen arm trgsel begin dbgbrk 0 capmod w reset 0 0 0 00000 = unimplemented or reserved figure 7-4. debug control register (dbgc1) table 7-3. dbgc1 field descriptions field description 7 dbgen dbg mode enable bit ?the dbgen bit enables the dbg module for use in dbg mode. this bit cannot be set if the mcu is in secure mode. 0 dbg mode disabled 1 dbg mode enabled 6 arm arm bit ?the arm bit controls whether the debugger is comparing and storing data in the trace buffer. see section 7.4.2.4, ?rming the dbg module , for more information. 0 debugger unarmed 1 debugger armed note: this bit cannot be set if the dbgen bit is not also being set at the same time. for example, a write of 01 to dbgen[7:6] will be interpreted as a write of 00. 5 trgsel trigger selection bit ?the trgsel bit controls the triggering condition for comparators a and b in dbg mode. it serves essentially the same function as the tagab bit in the dbgc2 register does in bkp mode. see section 7.4.2.1.2, ?rigger selection , for more information. trgsel may also determine the type of breakpoint based on comparator a and b if enabled in dbg mode (dbgbrk = 1). please refer to section 7.4.3.1, ?reakpoint based on comparator a and b . 0 trigger on any compare address match 1 trigger before opcode at compare address gets executed (tagged-type) 4 begin begin/end trigger bit the begin bit controls whether the trigger begins or ends storing of data in the trace buffer. see section 7.4.2.8.1, ?toring with begin-trigger , and section 7.4.2.8.2, ?toring with end-trigger , for more details. 0 trigger at end of stored data 1 trigger before storing data
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 199 rev 1.09 3 dbgbrk dbg breakpoint enable bit the dbgbrk bit controls whether the debugger will request a breakpoint based on comparator a and b to the cpu upon completion of a tracing session. please refer to section 7.4.3, ?reakpoints , for further details. 0 cpu break request not enabled 1 cpu break request enabled 1:0 capmod capture mode field ?see table 7-4 for capture mode ?ld de?itions. in loop1 mode, the debugger will automatically inhibit redundant entries into capture memory. in detail mode, the debugger is storing address and data for all cycles except program fetch (p) and free (f) cycles. in pro?e mode, the debugger is returning the address of the last instruction executed by the cpu on each access of trace buffer address. refer to section 7.4.2.6, ?apture modes , for more information. table 7-4. capmod encoding capmod description 00 normal 01 loop1 10 detail 11 profile table 7-3. dbgc1 field descriptions (continued) field description
chapter 7 debug module (dbgv1) block description 200 mc9s12q128 freescale semiconductor rev 1.09 7.3.2.2 debug status and control register (dbgsc) module base + 0x0021 starting address location affected by initrg register setting. 76543210 raf bf cf 0 trg w reset 0 0 0 00000 = unimplemented or reserved figure 7-5. debug status and control register (dbgsc) table 7-5. dbgsc field descriptions field description 7 af trigger a match flag ?the af bit indicates if trigger a match condition was met since arming. this bit is cleared when arm in dbgc1 is written to a 1 or on any write to this register. 0 trigger a did not match 1 trigger a match 6 bf trigger b match flag ?the bf bit indicates if trigger b match condition was met since arming.this bit is cleared when arm in dbgc1 is written to a 1 or on any write to this register. 0 trigger b did not match 1 trigger b match 5 cf comparator c match flag the cf bit indicates if comparator c match condition was met since arming.this bit is cleared when arm in dbgc1 is written to a 1 or on any write to this register. 0 comparator c did not match 1 comparator c match 3:0 trg trigger mode bits ?the trg bits select the trigger mode of the dbg module as shown table 7-6 . see section 7.4.2.5, ?rigger modes , for more detail. table 7-6. trigger mode encoding trg value meaning 0000 a only 0001 a or b 0010 a then b 0011 event only b 0100 a then event only b 0101 a and b (full mode) 0110 a and not b (full mode) 0111 inside range 1000 outside range 1001 1111 reserved (defaults to a only)
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 201 rev 1.09 7.3.2.3 debug trace buffer register (dbgtb) module base + 0x0022 starting address location affected by initrg register setting. 15 14 13 12 11 10 9 8 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset u u u uuuuu = unimplemented or reserved figure 7-6. debug trace buffer register high (dbgtbh) module base + 0x0023 starting address location affected by initrg register setting. 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset u u u uuuuu = unimplemented or reserved figure 7-7. debug trace buffer register low (dbgtbl) table 7-7. dbgtb field descriptions field description 15:0 trace buffer data bits the trace buffer data bits contain the data of the trace buffer. this register can be read only as a word read. any byte reads or misaligned access of these registers will return 0 and will not cause the trace buffer pointer to increment to the next trace buffer address. the same is true for word reads while the debugger is armed. in addition, this register may appear to contain incorrect data if it is not read with the same capture mode bit settings as when the trace buffer data was recorded (see section 7.4.2.9, ?eading data from trace buffer ?. because reads will re?ct the contents of the trace buffer ram, the reset state is unde?ed.
chapter 7 debug module (dbgv1) block description 202 mc9s12q128 freescale semiconductor rev 1.09 7.3.2.4 debug count register (dbgcnt) module base + 0x0024 starting address location affected by initrg register setting. 76543210 r tbf 0 cnt w reset 0 0 0 00000 = unimplemented or reserved figure 7-8. debug count register (dbgcnt) table 7-8. dbgcnt field descriptions field description 7 tbf trace buffer full the tbf bit indicates that the trace buffer has stored 64 or more words of data since it was last armed. if this bit is set, then all 64 words will be valid data, regardless of the value in cnt[5:0]. the tbf bit is cleared when arm in dbgc1 is written to a 1. 5:0 cnt count value the cnt bits indicate the number of valid data words stored in the trace buffer. table 7-9 shows the correlation between the cnt bits and the number of valid data words in the trace buffer. when the cnt rolls over to 0, the tbf bit will be set and incrementing of cnt will continue if dbg is in end-trigger mode. the dbgcnt register is cleared when arm in dbgc1 is written to a 1. table 7-9. cnt decoding table tbf cnt description 0 000000 no data valid 0 000001 1 word valid 0 000010 .. .. 111110 2 words valid .. .. 62 words valid 0 111111 63 words valid 1 000000 64 words valid; if begin = 1, the arm bit will be cleared. a breakpoint will be generated if dbgbrk = 1 1 000001 .. .. 111111 64 words valid, oldest data has been overwritten by most recent data
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 203 rev 1.09 7.3.2.5 debug comparator c extended register (dbgccx) module base + 0x0025 starting address location affected by initrg register setting. 76543210 r pagsel extcmp w reset 0 0 0 00000 figure 7-9. debug comparator c extended register (dbgccx) table 7-10. dbgccx field descriptions field description 7:6 pagsel page selector field in both bkp and dbg mode, pagsel selects the type of paging as shown in table 7-11 . dpage and epage are not yet implemented so the value in bit 7 will be ignored (i.e., pagsel values of 10 and 11 will be interpreted as values of 00 and 01, respectively). 5:0 extcmp comparator c extended compare bits the extcmp bits are used as comparison address bits as shown in table 7-11 along with the appropriate ppage, dpage, or epage signal from the core. note: comparator c can be used when the dbg module is con?ured for bkp mode. extended addressing comparisons for comparator c use pagsel and will operate differently to the way that comparator a and b operate in bkp mode. table 7-11. pagsel decoding (1) 1. see figure 7-10 . pagsel description extcmp comment 00 normal (64k) not used no paged memory 01 ppage (256 ?16k pages) extcmp[5:0] is compared to address bits [21:16] (2) 2. current hcs12 implementations have ppage limited to 6 bits. therefore, extcmp[5:4] should be set to 00. ppage[7:0] / xab[21:14] becomes address bits [21:14] 1 10 (3) 3. data page (dpage) and extra page (epage) are reserved for implementation on devices that support paged data and extra space. dpage (reserved) (256 ?4k pages) extcmp[3:0] is compared to address bits [19:16] dpage / xab[21:14] becomes address bits [19:12] 11 2 epage (reserved) (256 ?1k pages) extcmp[1:0] is compared to address bits [17:16] epage / xab[21:14] becomes address bits [17:10]
chapter 7 debug module (dbgv1) block description 204 mc9s12q128 freescale semiconductor rev 1.09 7.3.2.6 debug comparator c register (dbgcc) dbgcxx dbgcxh[15:12] pagsel extcmp bit 15 bit 14 bit 13 bit 12 76 0 5 0 4 3 2 1 bit 0 see note 1 portk/xab xab21 xab20 xab19 xab18 xab17 xab16 xab15 xab14 ppage pix7 pix6 pix5 pix4 pix3 pix2 pix1 pix0 see note 2 notes: 1. in bkp and dbg mode, pagsel selects the type of paging as shown in table 7-11 . 2. current hcs12 implementations are limited to six ppage bits, pix[5:0]. therefore, extcmp[5:4] = 00. figure 7-10. comparator c extended comparison in bkp/dbg mode module base + 0x0026 starting address location affected by initrg register setting. 15 14 13 12 11 10 9 8 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 0 0 0 00000 = unimplemented or reserved figure 7-11. debug comparator c register high (dbgcch) module base + 0x0027 starting address location affected by initrg register setting. 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 0 0 0 00000 = unimplemented or reserved figure 7-12. debug comparator c register low (dbgccl) bkp/dbg mode
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 205 rev 1.09 7.3.2.7 debug control register 2 (dbgc2) figure 7-13. debug control register 2 (dbgc2) table 7-12. dbgcc field descriptions field description 15:0 comparator c compare bits ?the comparator c compare bits control whether comparator c will compare the address bus bits [15:0] to a logic 1 or logic 0. see table 7-13 . 0 compare corresponding address bit to a logic 0 1 compare corresponding address bit to a logic 1 note: this register will be cleared automatically when the dbg module is armed in loop1 mode. table 7-13. comparator c compares pagsel extcmp compare high-byte compare x0 no compare dbgcch[7:0] = ab[15:8] x1 extcmp[5:0] = xab[21:16] dbgcch[7:0] = xab[15:14],ab[13:8] module base + 0x0028 starting address location affected by initrg register setting. 76543210 r bkaben (1) 1. when bkaben is set (bkp mode), all bits in dbgc2 are available. when bkaben is cleared and dbg is used in dbg mode, bits full and tagab have no meaning. full bdm tagab bkcen (2) 2. these bits can be used in bkp mode and dbg mode (when capture mode is not set in loop1) to provide a third breakpoint. tag c 2 rwcen 2 rwc 2 w reset 0 0 0 00000 table 7-14. dbgc2 field descriptions field description 7 bkaben breakpoint using comparator a and b enable this bit enables the breakpoint capability using comparator a and b, when set (bkp mode) the dbgen bit in dbgc1 cannot be set. 0 breakpoint module off 1 breakpoint module on 6 full full breakpoint mode enable this bit controls whether the breakpoint module is in dual mode or full mode. in full mode, comparator a is used to match address and comparator b is used to match data. see section 7.4.1.2, ?ull breakpoint mode , for more details. 0 dual address mode enabled 1 full breakpoint mode enabled 5 bdm background debug mode enable ?this bit determines if the breakpoint causes the system to enter background debug mode (bdm) or initiate a software interrupt (swi). 0 go to software interrupt on a break request 1 go to bdm on a break request
chapter 7 debug module (dbgv1) block description 206 mc9s12q128 freescale semiconductor rev 1.09 7.3.2.8 debug control register 3 (dbgc3) figure 7-14. debug control register 3 (dbgc3) 4 tagab comparator a/b tag select this bit controls whether the breakpoint will cause a break on the next instruction boundary (force) or on a match that will be an executable opcode (tagged). non-executed opcodes cannot cause a tagged breakpoint. 0 on match, break at the next instruction boundary (force) 1 on match, break if/when the instruction is about to be executed (tagged) 3 bkcen breakpoint comparator c enable bit ?this bit enables the breakpoint capability using comparator c. 0 comparator c disabled for breakpoint 1 comparator c enabled for breakpoint note: this bit will be cleared automatically when the dbg module is armed in loop1 mode. 2 tag c comparator c tag select this bit controls whether the breakpoint will cause a break on the next instruction boundary (force) or on a match that will be an executable opcode (tagged). non-executed opcodes cannot cause a tagged breakpoint. 0 on match, break at the next instruction boundary (force) 1 on match, break if/when the instruction is about to be executed (tagged) 1 rwcen read/write comparator c enable bit the rwcen bit controls whether read or write comparison is enabled for comparator c. rwcen is not useful for tagged breakpoints. 0 read/write is not used in comparison 1 read/write is used in comparison 0 rwc read/write comparator c value bit ?the rwc bit controls whether read or write is used in compare for comparator c. the rwc bit is not used if rwcen = 0. 0 write cycle will be matched 1 read cycle will be matched module base + 0x0029 starting address location affected by initrg register setting. 76543210 r bkambh (1) 1. in dbg mode, bkambh:bkambl has no meaning and are forced to 0s. bkambl 1 bkbmbh (2) 2. in dbg mode, bkbmbh:bkbmbl are used in full mode to qualify data. bkbmbl 2 rwaen rwa rwben rwb w reset 0 0 0 00000 table 7-14. dbgc2 field descriptions (continued) field description
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 207 rev 1.09 table 7-15. dbgc3 field descriptions field description 7:6 bkamb[h:l] breakpoint mask high byte for first address in dual or full mode, these bits may be used to mask (disable) the comparison of the high and/or low bytes of the ?st address breakpoint. the functionality is as given in table 7-16 . the x:0 case is for a full address compare. when a program page is selected, the full address compare will be based on bits for a 20-bit compare. the registers used for the compare are {dbgcax[5:0], dbgcah[5:0], dbgcal[7:0]}, where dbgax[5:0] corresponds to ppage[5:0] or extended address bits [19:14] and cpu address [13:0]. when a program page is not selected, the full address compare will be based on bits for a 16-bit compare. the registers used for the compare are {dbgcah[7:0], dbgcal[7:0]} which corresponds to cpu address [15:0]. note: this extended address compare scheme causes an aliasing problem in bkp mode in which several physical addresses may match with a single logical address. this problem may be avoided by using dbg mode to generate breakpoints. the 1:0 case is not sensible because it would ignore the high order address and compare the low order and expansion addresses. logic forces this case to compare all address lines (effectively ignoring the bkambh control bit). the 1:1 case is useful for triggering a breakpoint on any access to a particular expansion page. this only makes sense if a program page is being accessed so that the breakpoint trigger will occur only if dbgcax compares. 5:4 bkbmb[h:l] breakpoint mask high byte and low byte of data (second address) ?in dual mode, these bits may be used to mask (disable) the comparison of the high and/or low bytes of the second address breakpoint. the functionality is as given in table 7-17 . the x:0 case is for a full address compare. when a program page is selected, the full address compare will be based on bits for a 20-bit compare. the registers used for the compare are {dbgcbx[5:0], dbgcbh[5:0], dbgcbl[7:0]} where dbgcbx[5:0] corresponds to ppage[5:0] or extended address bits [19:14] and cpu address [13:0]. when a program page is not selected, the full address compare will be based on bits for a 16-bit compare. the registers used for the compare are {dbgcbh[7:0], dbgcbl[7:0]} which corresponds to cpu address [15:0]. note: this extended address compare scheme causes an aliasing problem in bkp mode in which several physical addresses may match with a single logical address. this problem may be avoided by using dbg mode to generate breakpoints. the 1:0 case is not sensible because it would ignore the high order address and compare the low order and expansion addresses. logic forces this case to compare all address lines (effectively ignoring the bkbmbh control bit). the 1:1 case is useful for triggering a breakpoint on any access to a particular expansion page. this only makes sense if a program page is being accessed so that the breakpoint trigger will occur only if dbgcbx compares. in full mode, these bits may be used to mask (disable) the comparison of the high and/or low bytes of the data breakpoint. the functionality is as given in table 7-18 . 3 rwaen read/write comparator a enable bit the rwaen bit controls whether read or write comparison is enabled for comparator a. see section 7.4.2.1.1, ?ead or write comparison , for more information. this bit is not useful for tagged operations. 0 read/write is not used in comparison 1 read/write is used in comparison 2 rwa read/write comparator a value bit ?the rwa bit controls whether read or write is used in compare for comparator a. the rwa bit is not used if rwaen = 0. 0 write cycle will be matched 1 read cycle will be matched
chapter 7 debug module (dbgv1) block description 208 mc9s12q128 freescale semiconductor rev 1.09 1 rwben read/write comparator b enable bit the rwben bit controls whether read or write comparison is enabled for comparator b. see section 7.4.2.1.1, ?ead or write comparison , for more information. this bit is not useful for tagged operations. 0 read/write is not used in comparison 1 read/write is used in comparison 0 rwb read/write comparator b value bit ?the rwb bit controls whether read or write is used in compare for comparator b. the rwb bit is not used if rwben = 0. 0 write cycle will be matched 1 read cycle will be matched note: rwb and rwben are not used in full mode. table 7-16. breakpoint mask bits for first address bkambh:bkambl address compare dbgcax dbgcah dbgcal x:0 full address compare yes (1) 1. if ppage is selected. ye s ye s 0:1 256 byte address range yes 1 ye s n o 1:1 16k byte address range yes 1 no no table 7-17. breakpoint mask bits for second address (dual mode) bkbmbh:bkbmbl address compare dbgcbx dbgcbh dbgcbl x:0 full address compare yes (1) 1. if ppage is selected. ye s ye s 0:1 256 byte address range yes 1 ye s n o 1:1 16k byte address range yes 1 no no table 7-18. breakpoint mask bits for data breakpoints (full mode) bkbmbh:bkbmbl data compare dbgcbx dbgcbh dbgcbl 0:0 high and low byte compare no (1) 1. expansion addresses for breakpoint b are not applicable in this mode. ye s ye s 0:1 high byte no 1 ye s n o 1:0 low byte no 1 no yes 1:1 no compare no 1 no no table 7-15. dbgc3 field descriptions (continued) field description
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 209 rev 1.09 7.3.2.9 debug comparator a extended register (dbgcax) module base + 0x002a starting address location affected by initrg register setting. 76543210 r pagsel extcmp w reset 0 0 0 00000 figure 7-15. debug comparator a extended register (dbgcax) table 7-19. dbgcax field descriptions field description 7:6 pagsel page selector field if dbgen is set in dbgc1, then pagsel selects the type of paging as shown in ta bl e 7 - 20 . dpage and epage are not yet implemented so the value in bit 7 will be ignored (i.e., pagsel values of 10 and 11 will be interpreted as values of 00 and 01, respectively). in bkp mode, pagsel has no meaning and extcmp[5:0] are compared to address bits [19:14] if the address is in the flash/rom memory space. 5:0 extcmp comparator a extended compare bits the extcmp bits are used as comparison address bits as shown in table 7-20 along with the appropriate ppage, dpage, or epage signal from the core. table 7-20. comparator a or b compares mode extcmp compare high-byte compare bkp (1) 1. see figure 7-16 . not flash/rom access no compare dbgcxh[7:0] = ab[15:8] flash/rom access extcmp[5:0] = xab[19:14] dbgcxh[5:0] = ab[13:8] dbg (2) 2. see figure 7-10 (note that while this ?ure provides extended comparisons for comparator c, the ?ure also pertains to comparators a and b in dbg mode only). pagsel = 00 no compare dbgcxh[7:0] = ab[15:8] pagsel = 01 extcmp[5:0] = xab[21:16] dbgcxh[7:0] = xab[15:14], ab[13:8]
chapter 7 debug module (dbgv1) block description 210 mc9s12q128 freescale semiconductor rev 1.09 7.3.2.10 debug comparator a register (dbgca) pagsel extcmp dbgcxx 0 0 54321 bit 0 see note 1 portk/xab xab21 xab20 xab19 xab18 xab17 xab16 xab15 xab14 ppage pix7 pix6 pix5 pix4 pix3 pix2 pix1 pix0 see note 2 notes: 1. in bkp mode, pagsel has no functionality. therefore, set pagsel to 00 (reset state). 2. current hcs12 implementations are limited to six ppage bits, pix[5:0]. figure 7-16. comparators a and b extended comparison in bkp mode module base + 0x002b starting address location affected by initrg register setting. 15 14 13 12 11 10 9 8 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 0 0 0 00000 figure 7-17. debug comparator a register high (dbgcah) module base + 0x002c starting address location affected by initrg register setting. 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 0 0 0 00000 figure 7-18. debug comparator a register low (dbgcal) table 7-21. dbgca field descriptions field description 15:0 15:0 comparator a compare bits the comparator a compare bits control whether comparator a compares the address bus bits [15:0] to a logic 1 or logic 0. see table 7-20 . 0 compare corresponding address bit to a logic 0 1 compare corresponding address bit to a logic 1 bkp mode
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 211 rev 1.09 7.3.2.11 debug comparator b extended register (dbgcbx) 7.3.2.12 debug comparator b register (dbgcb) module base + 0x002d 76543210 r pagsel extcmp w reset 0 0 0 00000 figure 7-19. debug comparator b extended register (dbgcbx) table 7-22. dbgcbx field descriptions field description 7:6 pagsel page selector field if dbgen is set in dbgc1, then pagsel selects the type of paging as shown in ta bl e 7 - 11 . dpage and epage are not yet implemented so the value in bit 7 will be ignored (i.e., pagsel values of 10 and 11 will be interpreted as values of 00 and 01, respectively.) in bkp mode, pagsel has no meaning and extcmp[5:0] are compared to address bits [19:14] if the address is in the flash/rom memory space. 5:0 extcmp comparator b extended compare bits the extcmp bits are used as comparison address bits as shown in table 7-11 along with the appropriate ppage, dpage, or epage signal from the core. also see table 7-20 . module base + 0x002e starting address location affected by initrg register setting. 15 14 13 12 11 10 9 8 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 0 0 0 00000 figure 7-20. debug comparator b register high (dbgcbh)
chapter 7 debug module (dbgv1) block description 212 mc9s12q128 freescale semiconductor rev 1.09 7.4 functional description this section provides a complete functional description of the dbg module. the dbg module can be con?ured to run in either of two modes, bkp or dbg. bkp mode is enabled by setting bkaben in dbgc2. dbg mode is enabled by setting dbgen in dbgc1. setting bkaben in dbgc2 overrides the dbgen in dbgc1 and prevents dbg mode. if the part is in secure mode, dbg mode cannot be enabled. 7.4.1 dbg operating in bkp mode in bkp mode, the dbg will be fully backwards compatible with the existing bkp_st12_a module. the dbgc2 register has four additional bits that were not available on existing bkp_st12_a modules. as long as these bits are written to either all 1s or all 0s, they should be transparent to the user. all 1s would enable comparator c to be used as a breakpoint, but tagging would be enabled. the match address register would be all 0s if not modi?d by the user. therefore, code executing at address 0x0000 would have to occur before a breakpoint based on comparator c would happen. the dbg module in bkp mode supports two modes of operation: dual address mode and full breakpoint mode. within each of these modes, forced or tagged breakpoint types can be used. forced breakpoints occur at the next instruction boundary if a match occurs and tagged breakpoints allow for breaking just before the tagged instruction executes. the action taken upon a successful match can be to either place the cpu in background debug mode or to initiate a software interrupt. the breakpoint can operate in dual address mode or full breakpoint mode. each of these modes is discussed in the subsections below. 7.4.1.1 dual address mode when dual address mode is enabled, two address breakpoints can be set. each breakpoint can cause the system to enter background debug mode or to initiate a software interrupt based upon the state of bdm in module base + 0x002f starting address location affected by initrg register setting. 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 0 0 0 00000 figure 7-21. debug comparator b register low (dbgcbl) table 7-23. dbgcb field descriptions field description 15:0 15:0 comparator b compare bits the comparator b compare bits control whether comparator b compares the address bus bits [15:0] or data bus bits [15:0] to a logic 1 or logic 0. see table 7-20 . 0 compare corresponding address bit to a logic 0, compares to data if in full mode 1 compare corresponding address bit to a logic 1, compares to data if in full mode
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 213 rev 1.09 dbgc2 being logic 1 or logic 0, respectively. bdm requests have a higher priority than swi requests. no data breakpoints are allowed in this mode. tagab in dbgc2 selects whether the breakpoint mode is forced or tagged. the bkxmbh:l bits in dbgc3 select whether or not the breakpoint is matched exactly or is a range breakpoint. they also select whether the address is matched on the high byte, low byte, both bytes, and/or memory expansion. the rwx and rwxen bits in dbgc3 select whether the type of bus cycle to match is a read, write, or read/write when performing forced breakpoints. 7.4.1.2 full breakpoint mode full breakpoint mode requires a match on address and data for a breakpoint to occur. upon a successful match, the system will enter background debug mode or initiate a software interrupt based upon the state of bdm in dbgc2 being logic 1 or logic 0, respectively. bdm requests have a higher priority than swi requests. r/w matches are also allowed in this mode. tagab in dbgc2 selects whether the breakpoint mode is forced or tagged. when tagab is set in dbgc2, only addresses are compared and data is ignored. the bkambh:l bits in dbgc3 select whether or not the breakpoint is matched exactly, is a range breakpoint, or is in page space. the bkbmbh:l bits in dbgc3 select whether the data is matched on the high byte, low byte, or both bytes. rwa and rwaen bits in dbgc2 select whether the type of bus cycle to match is a read or a write when performing forced breakpoints. rwb and rwben bits in dbgc2 are not used in full breakpoint mode. note the full trigger mode is designed to be used for either a word access or a byte access, but not both at the same time. confusing trigger operation (seemingly false triggers or no trigger) can occur if the trigger address occurs in the user program as both byte and word accesses. 7.4.1.3 breakpoint priority breakpoint operation is ?st determined by the state of the bdm module. if the bdm module is already active, meaning the cpu is executing out of bdm ?mware, breakpoints are not allowed. in addition, while executing a bdm trace command, tagging into bdm is not allowed. if bdm is not active, the breakpoint will give priority to bdm requests over swi requests. this condition applies to both forced and tagged breakpoints. in all cases, bdm related breakpoints will have priority over those generated by the breakpoint sub-block. this priority includes breakpoints enabled by the t a glo and t a ghi external pins of the system that interface with the bdm directly and whose signal information passes through and is used by the breakpoint sub-block.
chapter 7 debug module (dbgv1) block description 214 mc9s12q128 freescale semiconductor rev 1.09 note bdm should not be entered from a breakpoint unless the enable bit is set in the bdm. even if the enable bit in the bdm is cleared, the cpu actually executes the bdm ?mware code. it checks the enable and returns if enable is not set. if the bdm is not serviced by the monitor then the breakpoint would be re-asserted when the bdm returns to normal cpu ?w. there is no hardware to enforce restriction of breakpoint operation if the bdm is not enabled. when program control returns from a tagged breakpoint through an rti or a bdm go command, it will return to the instruction whose tag generated the breakpoint. unless breakpoints are disabled or modi?d in the service routine or active bdm session, the instruction will be tagged again and the breakpoint will be repeated. in the case of bdm breakpoints, this situation can also be avoided by executing a trace1 command before the go to increment the program ?w past the tagged instruction. 7.4.1.4 using comparator c in bkp mode the original bkp_st12_a module supports two breakpoints. the dbg_st12_a module can be used in bkp mode and allow a third breakpoint using comparator c. four additional bits, bkcen, tagc, rwcen, and rwc in dbgc2 in conjunction with additional comparator c address registers, dbgccx, dbgcch, and dbgccl allow the user to set up a third breakpoint. using pagsel in dbgccx for expanded memory will work differently than the way paged memory is done using comparator a and b in bkp mode. see section 7.3.2.5, ?ebug comparator c extended register (dbgccx) , for more information on using comparator c. 7.4.2 dbg operating in dbg mode enabling the dbg module in dbg mode, allows the arming, triggering, and storing of data in the trace buffer and can be used to cause cpu breakpoints. the dbg module is made up of three main blocks, the comparators, trace buffer control logic, and the trace buffer. note in general, there is a latency between the triggering event appearing on the bus and being detected by the dbg circuitry. in general, tagged triggers will be more predictable than forced triggers. 7.4.2.1 comparators the dbg contains three comparators, a, b, and c. comparator a compares the core address bus with the address stored in dbgcah and dbgcal. comparator b compares the core address bus with the address stored in dbgcbh and dbgcbl except in full mode, where it compares the data buses to the data stored in dbgcbh and dbgcbl. comparator c can be used as a breakpoint generator or as the address comparison unit in the loop1 mode. matches on comparator a, b, and c are signaled to the trace buffer
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 215 rev 1.09 control (tbc) block. when pagsel = 01, registers dbgcax, dbgcbx, and dbgccx are used to match the upper addresses as shown in table 7-11 . note if a tagged-type c breakpoint is set at the same address as an a/b tagged- type trigger (including the initial entry in an inside or outside range trigger), the c breakpoint will have priority and the trigger will not be recognized. 7.4.2.1.1 read or write comparison read or write comparisons are useful only with trgsel = 0, because only opcodes should be tagged as they are ?ead?from memory. rwaen and rwben are ignored when trgsel = 1. in full modes (a and b?and a and not b? rwaen and rwa are used to select read or write comparisons for both comparators a and b. table 7-24 shows the effect for rwaen, rwa, and rw on the dbgcb comparison conditions. the rwben and rwb bits are not used and are ignored in full modes. 7.4.2.1.2 trigger selection the trgsel bit in dbgc1 is used to determine the triggering condition in dbg mode. trgsel applies to both trigger a and b except in the event only trigger modes. by setting trgsel, the comparators a and b will qualify a match with the output of opcode tracking logic and a trigger occurs before the tagged instruction executes (tagged-type trigger). with the trgsel bit cleared, a comparator match forces a trigger when the matching condition occurs (force-type trigger). note if the trgsel is set, the address stored in the comparator match address registers must be an opcode address for the trigger to occur. 7.4.2.2 trace buffer control (tbc) the tbc is the main controller for the dbg module. its function is to decide whether data should be stored in the trace buffer based on the trigger mode and the match signals from the comparator. the tbc also determines whether a request to break the cpu should occur. table 7-24. read or write comparison logic table rwaen bit rwa bit rw signal comment 0 x 0 write data bus 0 x 1 read data bus 1 0 0 write data bus 1 0 1 no data bus compare since rw=1 1 1 0 no data bus compare since rw=0 1 1 1 read data bus
chapter 7 debug module (dbgv1) block description 216 mc9s12q128 freescale semiconductor rev 1.09 7.4.2.3 begin- and end-trigger the de?itions of begin- and end-trigger as used in the dbg module are as follows: begin-trigger: storage in trace buffer occurs after the trigger and continues until 64 locations are ?led. end-trigger: storage in trace buffer occurs until the trigger, with the least recent data falling out of the trace buffer if more than 64 words are collected. 7.4.2.4 arming the dbg module in dbg mode, arming occurs by setting dbgen and arm in dbgc1. the arm bit in dbgc1 is cleared when the trigger condition is met in end-trigger mode or when the trace buffer is ?led in begin-trigger mode. the tbc logic determines whether a trigger condition has been met based on the trigger mode and the trigger selection. 7.4.2.5 trigger modes the dbg module supports nine trigger modes. the trigger modes are encoded as shown in table 7-6 . the trigger mode is used as a quali?r for either starting or ending the storing of data in the trace buffer. when the match condition is met, the appropriate ?g a or b is set in dbgsc. arming the dbg module clears the a, b, and c ?gs in dbgsc. in all trigger modes except for the event-only modes and detail capture mode, change-of-?w addresses are stored in the trace buffer. in the event-only modes only the value on the data bus at the trigger event b will be stored. in detail capture mode address and data for all cycles except program fetch (p) and free (f) cycles are stored in trace buffer. 7.4.2.5.1 a only in the a only trigger mode, if the match condition for a is met, the a ?g in dbgsc is set and a trigger occurs. 7.4.2.5.2 a or b in the a or b trigger mode, if the match condition for a or b is met, the corresponding ?g in dbgsc is set and a trigger occurs. 7.4.2.5.3 a then b in the a then b trigger mode, the match condition for a must be met before the match condition for b is compared. when the match condition for a or b is met, the corresponding ?g in dbgsc is set. the trigger occurs only after a then b have matched. note when tagging and using a then b, if addresses a and b are close together, then b may not complete the trigger sequence. this occurs when a and b are in the instruction queue at the same time. basically the a trigger has not yet occurred, so the b instruction is not tagged. generally, if address b is at
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 217 rev 1.09 least six addresses higher than address a (or b is lower than a) and there are not changes of ?w to put these in the queue at the same time, then this operation should trigger properly. 7.4.2.5.4 event-only b (store data) in the event-only b trigger mode, if the match condition for b is met, the b ?g in dbgsc is set and a trigger occurs. the event-only b trigger mode is considered a begin-trigger type and the begin bit in dbgc1 is ignored. event-only b is incompatible with instruction tagging (trgsel = 1), and thus the value of trgsel is ignored. please refer to section 7.4.2.7, ?torage memory , for more information. this trigger mode is incompatible with the detail capture mode so the detail capture mode will have priority. trgsel and begin will not be ignored and this trigger mode will behave as if it were ? only? 7.4.2.5.5 a then event-only b (store data) in the a then event-only b trigger mode, the match condition for a must be met before the match condition for b is compared, after the a match has occurred, a trigger occurs each time b matches. when the match condition for a or b is met, the corresponding ?g in dbgsc is set. the a then event-only b trigger mode is considered a begin-trigger type and begin in dbgc1 is ignored. trgsel in dbgc1 applies only to the match condition for a. please refer to section 7.4.2.7, ?torage memory , for more information. this trigger mode is incompatible with the detail capture mode so the detail capture mode will have priority. trgsel and begin will not be ignored and this trigger mode will be the same as a then b. 7.4.2.5.6 a and b (full mode) in the a and b trigger mode, comparator a compares to the address bus and comparator b compares to the data bus. in the a and b trigger mode, if the match condition for a and b happen on the same bus cycle, both the a and b ?gs in the dbgsc register are set and a trigger occurs. if trgsel = 1, only matches from comparator a are used to determine if the trigger condition is met and comparator b matches are ignored. if trgsel = 0, full-word data matches on an odd address boundary (misaligned access) do not work unless the access is to a ram that manages misaligned accesses in a single clock cycle (which is typical of ram modules used in hcs12 mcus). 7.4.2.5.7 a and not b (full mode) in the a and not b trigger mode, comparator a compares to the address bus and comparator b compares to the data bus. in the a and not b trigger mode, if the match condition for a and not b happen on the same bus cycle, both the a and b ?gs in dbgsc are set and a trigger occurs. if trgsel = 1, only matches from comparator a are used to determine if the trigger condition is met and comparator b matches are ignored. as described in section 7.4.2.5.6, a and b (full mode) , full-word data compares on misaligned accesses will not match expected data (and thus will cause a trigger in this mode) unless the access is to a ram that manages misaligned accesses in a single clock cycle.
chapter 7 debug module (dbgv1) block description 218 mc9s12q128 freescale semiconductor rev 1.09 7.4.2.5.8 inside range (a address b) in the inside range trigger mode, if the match condition for a and b happen on the same bus cycle, both the a and b ?gs in dbgsc are set and a trigger occurs. if a match condition on only a or only b occurs no ?gs are set. if trgsel = 1, the inside range is accurate only to word boundaries. if trgsel = 0, an aligned word access which straddles the range boundary will cause a trigger only if the aligned address is within the range. 7.4.2.5.9 outside range (address < a or address > b) in the outside range trigger mode, if the match condition for a or b is met, the corresponding ?g in dbgsc is set and a trigger occurs. if trgsel = 1, the outside range is accurate only to word boundaries. if trgsel = 0, an aligned word access which straddles the range boundary will cause a trigger only if the aligned address is outside the range. 7.4.2.5.10 control bit priorities the de?itions of some of the control bits are incompatible with each other. table 7-25 and the notes associated with it summarize how these incompatibilities are managed: read/write comparisons are not compatible with trgsel = 1. therefore, rwaen and rwben are ignored. event-only trigger modes are always considered a begin-type trigger. see section 7.4.2.8.1, ?toring with begin-trigger , and section 7.4.2.8.2, ?toring with end-trigger . detail capture mode has priority over the event-only trigger/capture modes. therefore, event-only modes have no meaning in detail mode and their functions default to similar trigger modes. table 7-25. resolution of mode con?cts mode normal / loop1 detail tag force tag force a only a or b a then b event-only b 1 1, 3 3 a then event-only b 2 4 4 a and b (full mode) 5 5 a and not b (full mode) 5 5 inside range 6 6 outside range 6 6 1 ?ignored ?same as force 2 ?ignored for comparator b 3 ?reduces to effectively ? only 4 ?works same as a then b 5 ?reduces to effectively ? only??b not compared 6 ?only accurate to word boundaries
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 219 rev 1.09 7.4.2.6 capture modes the dbg in dbg mode can operate in four capture modes. these modes are described in the following subsections. 7.4.2.6.1 normal mode in normal mode, the dbg module uses comparator a and b as triggering devices. change-of-?w information or data will be stored depending on trg in dbgsc. 7.4.2.6.2 loop1 mode the intent of loop1 mode is to prevent the trace buffer from being ?led entirely with duplicate information from a looping construct such as delays using the dbne instruction or polling loops using brset/brclr instructions. immediately after address information is placed in the trace buffer, the dbg module writes this value into the c comparator and the c comparator is placed in ignore address mode. this will prevent duplicate address entries in the trace buffer resulting from repeated bit-conditional branches. comparator c will be cleared when the arm bit is set in loop1 mode to prevent the previous contents of the register from interfering with loop1 mode operation. breakpoints based on comparator c are disabled. loop1 mode only inhibits duplicate source address entries that would typically be stored in most tight looping constructs. it will not inhibit repeated entries of destination addresses or vector addresses, because repeated entries of these would most likely indicate a bug in the users code that the dbg module is designed to help ?d. note in certain very tight loops, the source address will have already been fetched again before the c comparator is updated. this results in the source address being stored twice before further duplicate entries are suppressed. this condition occurs with branch-on-bit instructions when the branch is fetched by the ?st p-cycle of the branch or with loop-construct instructions in which the branch is fetched with the ?st or second p cycle. see examples below: loop incx ; 1-byte instruction fetched by 1st p-cycle of brclr brclr cmptmp,#$0c,loop ; the brclr instruction also will be fetched by 1st p-cycle of brclr loop2 brn * ; 2-byte instruction fetched by 1st p-cycle of dbne nop ; 1-byte instruction fetched by 2nd p-cycle of dbne dbne a,loop2 ; this instruction also fetched by 2nd p-cycle of dbne note loop1 mode does not support paged memory, and inhibits duplicate entries in the trace buffer based solely on the cpu address. there is a remote possibility of an erroneous address match if program ?w alternates between paged and unpaged memory space.
chapter 7 debug module (dbgv1) block description 220 mc9s12q128 freescale semiconductor rev 1.09 7.4.2.6.3 detail mode in the detail mode, address and data for all cycles except program fetch (p) and free (f) cycles are stored in trace buffer. this mode is intended to supply additional information on indexed, indirect addressing modes where storing only the destination address would not provide all information required for a user to determine where his code was in error. 7.4.2.6.4 pro?e mode this mode is intended to allow a host computer to poll a running target and provide a histogram of program execution. each read of the trace buffer address will return the address of the last instruction executed. the dbgcnt register is not incremented and the trace buffer does not get ?led. the arm bit is not used and all breakpoints and all other debug functions will be disabled. 7.4.2.7 storage memory the storage memory is a 64 words deep by 16-bits wide dual port ram array. the cpu accesses the ram array through a single memory location window (dbgtbh:dbgtbl). the dbg module stores trace information in the ram array in a circular buffer format. as data is read via the cpu, a pointer into the ram will increment so that the next cpu read will receive fresh information. in all trigger modes except for event-only and detail capture mode, the data stored in the trace buffer will be change-of-?w addresses. change-of-?w addresses are de?ed as follows: source address of conditional branches (long, short, brset, and loop constructs) taken destination address of indexed jmp, jsr, and call instruction destination address of rti, rts, and rtc instructions vector address of interrupts except for swi and bdm vectors in the event-only trigger modes only the 16-bit data bus value corresponding to the event is stored. in the detail capture mode, address and then data are stored for all cycles except program fetch (p) and free (f) cycles. 7.4.2.8 storing data in memory storage buffer 7.4.2.8.1 storing with begin-trigger storing with begin-trigger can be used in all trigger modes. when dbg mode is enabled and armed in the begin-trigger mode, data is not stored in the trace buffer until the trigger condition is met. as soon as the trigger condition is met, the dbg module will remain armed until 64 words are stored in the trace buffer. if the trigger is at the address of the change-of-?w instruction the change-of-?w associated with the trigger event will be stored in the trace buffer. 7.4.2.8.2 storing with end-trigger storing with end-trigger cannot be used in event-only trigger modes. when dbg mode is enabled and armed in the end-trigger mode, data is stored in the trace buffer until the trigger condition is met. when the trigger condition is met, the dbg module will become de-armed and no more data will be stored. if
chapter 7 debug module (dbgv1) block description freescale semiconductor mc9s12q128 221 rev 1.09 the trigger is at the address of a change-of-?w address the trigger event will not be stored in the trace buffer. 7.4.2.9 reading data from trace buffer the data stored in the trace buffer can be read using either the background debug module (bdm) module or the cpu provided the dbg module is enabled and not armed. the trace buffer data is read out ?st-in ?st-out. by reading cnt in dbgcnt the number of valid words can be determined. cnt will not decrement as data is read from dbgtbh:dbgtbl. the trace buffer data is read by reading dbgtbh:dbgtbl with a 16-bit read. each time dbgtbh:dbgtbl is read, a pointer in the dbg will be incremented to allow reading of the next word. reading the trace buffer while the dbg module is armed will return invalid data and no shifting of the ram pointer will occur. note the trace buffer should be read with the dbg module enabled and in the same capture mode that the data was recorded. the contents of the trace buffer counter register (dbgcnt) are resolved differently in detail mode verses the other modes and may lead to incorrect interpretation of the trace buffer data. 7.4.3 breakpoints there are two ways of getting a breakpoint in dbg mode. one is based on the trigger condition of the trigger mode using comparator a and/or b, and the other is using comparator c. external breakpoints generated using the t a ghi and t a glo external pins are disabled in dbg mode. 7.4.3.1 breakpoint based on comparator a and b a breakpoint request to the cpu can be enabled by setting dbgbrk in dbgc1. the value of begin in dbgc1 determines when the breakpoint request to the cpu will occur. when begin in dbgc1 is set, begin-trigger is selected and the breakpoint request will not occur until the trace buffer is ?led with 64 words. when begin in dbgc1 is cleared, end-trigger is selected and the breakpoint request will occur immediately at the trigger cycle. there are two types of breakpoint requests supported by the dbg module, tagged and forced. tagged breakpoints are associated with opcode addresses and allow breaking just before a speci? instruction executes. forced breakpoints are not associated with opcode addresses and allow breaking at the next instruction boundary. the type of breakpoint based on comparators a and b is determined by trgsel in the dbgc1 register (trgsel = 1 for tagged breakpoint, trgsel = 0 for forced breakpoint). table 7-26 illustrates the type of breakpoint that will occur based on the debug run.
chapter 7 debug module (dbgv1) block description 222 mc9s12q128 freescale semiconductor rev 1.09 7.4.3.2 breakpoint based on comparator c a breakpoint request to the cpu can be created if bkcen in dbgc2 is set. breakpoints based on a successful comparator c match can be accomplished regardless of the mode of operation for comparator a or b, and do not affect the status of the arm bit. tagc in dbgc2 is used to select either tagged or forced breakpoint requests for comparator c. breakpoints based on comparator c are disabled in loop1 mode. note because breakpoints cannot be disabled when the dbg is armed, one must be careful to avoid an ?n?ite breakpoint loop when using tagged-type c breakpoints while the dbg is armed. if bdm breakpoints are selected, executing a trace1 instruction before the go instruction is the recommended way to avoid re-triggering a breakpoint if one does not wish to de-arm the dbg. if swi breakpoints are selected, disarming the dbg in the swi interrupt service routine is the recommended way to avoid re- triggering a breakpoint. 7.5 resets the dbg module is disabled after reset. the dbg module cannot cause a mcu reset. 7.6 interrupts the dbg contains one interrupt source. if a breakpoint is requested and bdm in dbgc2 is cleared, an swi interrupt will be generated. table 7-26. breakpoint setup begin trgsel dbgbrk type of debug run 0 0 0 fill trace buffer until trigger address (no cpu breakpoint ?keep running) 0 0 1 fill trace buffer until trigger address, then a forced breakpoint request occurs 0 1 0 fill trace buffer until trigger opcode is about to execute (no cpu breakpoint ?keep running) 0 1 1 fill trace buffer until trigger opcode about to execute, then a tagged breakpoint request occurs 1 0 0 start trace buffer at trigger address (no cpu breakpoint ?keep running) 1 0 1 start trace buffer at trigger address, a forced breakpoint request occurs when trace buffer is full 1 1 0 start trace buffer at trigger opcode (no cpu breakpoint ?keep running) 1 1 1 start trace buffer at trigger opcode, a forced breakpoint request occurs when trace buffer is full
freescale semiconductor mc9s12q128 223 rev 1.09 chapter 8 analog-to-digital converter (atd10b8c) block description 8.1 introduction the atd10b8c is an 8-channel, 10-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. the block is designed to be upwards compatible with the 68hc11 standard 8-bit a/d converter. in addition, there are new operating modes that are unique to the hc12 design. 8.1.1 features 8/10-bit resolution. ? sec, 10-bit single conversion time. sample buffer ampli?r. programmable sample time. left/right justi?d, signed/unsigned result data. external trigger control. conversion completion interrupt generation. analog input multiplexer for eight analog input channels. analog/digital input pin multiplexing. 1-to-8 conversion sequence lengths. continuous conversion mode. multiple channel scans. 8.1.2 modes of operation 8.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels .
chapter 8 analog-to-digital converter (atd10b8c) block description 224 mc9s12q128 freescale semiconductor rev 1.09 8.1.2.2 mcu operating modes stop mode entering stop mode causes all clocks to halt and thus the system is placed in a minimum power standby mode. this aborts any conversion sequence in progress. during recovery from stop mode, there must be a minimum delay for the stop recovery time, t sr , before initiating a new atd conversion sequence. wait mode entering wait mode the atd conversion either continues or aborts for low power depending on the logical value of the await bit. freeze mode in freeze mode the atd10b8c will behave according to the logical values of the frz1 and frz0 bits. this is useful for debugging and emulation. 8.1.3 block diagram figure 8-1 is a block diagram of the atd. figure 8-1. atd10b8c block diagram v rl an0 / pad0 atd10b8c port ad data register analog mux mode and timing control successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac an7 / pad7 an6 / pad6 an5 / pad5 an4 / pad4 an3 / pad3 an2 / pad2 an1 / pad1 sample & hold 1 1 v rh v ssa v dda conversion complete interrupt + comparator clock prescaler bus clock atd clock atd input enable register
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 225 rev 1.09 8.2 signal description the atd10b8c has a total of 12 external pins. 8.2.1 an7 / etrig / pad7 this pin serves as the analog input channel 7. it can be con?ured to provide an external trigger for the atd conversion. it can be con?ured as general-purpose digital i/o. 8.2.2 an6 / pad6 this pin serves as the analog input channel 6. it can be con?ured as general-purpose digital i/o. 8.2.3 an5 / pad5 this pin serves as the analog input channel 5. it can be con?ured as general-purpose digital i/o. 8.2.4 an4 / pad4 this pin serves as the analog input channel 4. it can be con?ured as general-purpose digital i/o. 8.2.5 an3 / pad3 this pin serves as the analog input channel 3. it can be con?ured as general-purpose digital i/o. 8.2.6 an2 / pad2 this pin serves as the analog input channel 2. it can be con?ured as general-purpose digital i/o. 8.2.7 an1 / pad1 this pin serves as the analog input channel 1. it can be con?ured as general-purpose digital i/o. 8.2.8 an0 / pad0 this pin serves as the analog input channel 0. it can be con?ured as general-purpose digital i/o. 8.2.9 v rh , v rl v rh is the high reference voltage and v rl is the low reference voltage for atd conversion. 8.2.10 v dda , v ssa these pins are the power supplies for the analog circuitry of the atd10b8c block.
chapter 8 analog-to-digital converter (atd10b8c) block description 226 mc9s12q128 freescale semiconductor rev 1.09 8.3 memory map and registers this section provides a detailed description of all registers accessible in the atd10b8c. 8.3.1 module memory map figure 8-2 gives an overview on all atd10b8c registers. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 atdctl0 r0 00000 0 0 w 0x0001 atdctl1 r0 00000 0 0 w 0x0002 atdctl2 r adpu affc awai etrigle etrigp etrige ascie ascif w 0x0003 atdctl3 r0 s8c s4c s2c s1c fifo frz1 frz0 w 0x0004 atdctl4 r sres8 smp1 smp0 prs4 prs3 prs2 prs1 prs0 w 0x0005 atdctl5 r djm dsgn scan mult 0 cc cb ca w 0x0006 atdstat0 r scf 0 etorf fifor 0 cc2 cc1 cc0 w 0x0007 unimplemented r0 00000 0 0 w 0x0008 atdtest0 ru uuuuu u u w 0x0009 atdtest1 ru uuuuu u sc w 0x000a unimplemented r0 00000 0 0 w 0x000b atdstat1 r ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 w 0x000c unimplemented r0 00000 0 0 w 0x000d atddien r ien7 ien6 ien5 ien4 ien3 ien2 ien1 ien0 w 0x000e unimplemented r0 00000 0 0 w 0x000f portad r ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 w = unimplemented or reserved figure 8-2. atd register summary (sheet 1 of 4)
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 227 rev 1.09 left justi?d result data 0x0010 atddr0h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x0011 atddr0l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w 0x0012 atddr1h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x0013 atddr1l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w 0x0014 atddr2h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x0015 atddr2l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w 0x0016 atddr3h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x0017 atddr3l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w 0x0018 atddr4h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x0019 atddr4l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w 0x001a atddr5h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x001b atddr5l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w 0x001c atddr6h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x001d atddr6l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 8-2. atd register summary (sheet 2 of 4)
chapter 8 analog-to-digital converter (atd10b8c) block description 228 mc9s12q128 freescale semiconductor rev 1.09 0x001e atddr7h r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 w 0x001f atddr7l r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w right justi?d result data 0x0010 atddr0h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x0011 atddr0l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w 0x0012 atddr1h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x0013 atddr1l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w 0x0014 atddr2h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x0015 atddr2l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w 0x0016 atddr3h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x0017 atddr3l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w 0x0018 atddr4h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x0019 atddr4l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w 0x001a atddr5h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x001b atddr5l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 8-2. atd register summary (sheet 3 of 4)
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 229 rev 1.09 note register address = module base address + address offset, where the module base address is de?ed at the mcu level and the address offset is de?ed at the module level. 0x001c atddr6h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x001d atddr6l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w 0x001e atddr7h r0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 w 0x001f atddr7l r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 8-2. atd register summary (sheet 4 of 4)
chapter 8 analog-to-digital converter (atd10b8c) block description 230 mc9s12q128 freescale semiconductor rev 1.09 8.3.2 register descriptions this section describes in address order all the atd10b8c registers and their individual bits. 8.3.2.1 reserved register (atdctl0) read: always read $00 in normal modes write: unimplemented in normal modes 8.3.2.2 reserved register (atdctl1) read: always read $00 in normal modes write: unimplemented in normal modes note writing to this registers when in special modes can alter functionality. module base + 0x0000 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 8-3. reserved register (atdctl0) module base + 0x0001 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 8-4. reserved register (atdctl1)
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 231 rev 1.09 8.3.2.3 atd control register 2 (atdctl2) this register controls power down, interrupt, and external trigger. writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime module base + 0x0002 76543210 r adpu affc awai etrigle etrigp etrige ascie ascif w reset 0 0 0 00000 = unimplemented or reserved figure 8-5. atd control register 2 (atdctl2) table 8-1. atdctl2 field descriptions field description 7 adpu atd power down ?this bit provides on/off control over the atd10b8c block allowing reduced mcu power consumption. because analog electronic is turned off when powered down, the atd requires a recovery time period after adpu bit is enabled. 0 power down atd 1 normal atd functionality 6 affc atd fast flag clear all 0 atd ?g clearing operates normally (read the status register atdstat1 before reading the result register to clear the associate ccf ?g). 1 changes all atd conversion complete ?gs to a fast clear sequence. any access to a result register will cause the associate ccf ?g to clear automatically. 5 awai atd power down in wait mode when entering wait mode this bit provides on/off control over the atd10b8c block allowing reduced mcu power. because analog electronic is turned off when powered down, the atd requires a recovery time period after exit from wait mode. 0 atd continues to run in wait mode 1 halt conversion and power down atd during wait mode after exiting wait mode with an interrupt conversion will resume. but due to the recovery time the result of this conversion should be ignored. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 8-2 for details. 3 etrigp external trigger polarity this bit controls the polarity of the external trigger signal. see table 8-2 for details. 2 etrige external trigger mode enable ?this bit enables the external trigger on atd channel 7. the external trigger allows to synchronize sample and atd conversions processes with external events. 0 disable external trigger 1 enable external trigger note: the conversion results for the external trigger atd channel 7 have no meaning while external trigger mode is enabled.
chapter 8 analog-to-digital converter (atd10b8c) block description 232 mc9s12q128 freescale semiconductor rev 1.09 8.3.2.4 atd control register 3 (atdctl3) this register controls the conversion sequence length, fifo for results registers and behavior in freeze mode. writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd interrupt will be requested whenever ascif = 1 is set. 0 ascif atd sequence complete interrupt flag ?if ascie = 1 the ascif ?g equals the scf ?g (see section 8.3.2.7, ?td status register 0 (atdstat0) ), else ascif reads zero. writes have no effect. 0 no atd interrupt occurred 1 atd sequence complete interrupt pending table 8-2. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level module base + 0x0003 76543210 r0 s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 1 00000 = unimplemented or reserved figure 8-6. atd control register 3 (atdctl3) table 8-3. atdctl3 field descriptions field description 6? s8c, s4c, s2c, s1c conversion sequence length these bits control the number of conversions per sequence. table 8-4 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. table 8-1. atdctl2 field descriptions (continued) field description
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 233 rev 1.09 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register, the second result in the second result register, and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or ending of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc2-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion by write to an atdctl register (atdctl5-0) clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may or may not be useful in a particular application to track valid data. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? friz[1:0] background debug freeze enable ?when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 8-5 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period. table 8-4. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 00 0 0 8 00 0 1 1 00 1 0 2 00 1 1 3 01 0 0 4 01 0 1 5 01 1 0 6 01 1 1 7 1x x x 8 table 8-5. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately table 8-3. atdctl3 field descriptions (continued) field description
chapter 8 analog-to-digital converter (atd10b8c) block description 234 mc9s12q128 freescale semiconductor rev 1.09 8.3.2.5 atd control register 4 (atdctl4) this register selects the conversion clock frequency, the length of the second phase of the sample time and the resolution of the a/d conversion (i.e.: 8-bits or 10-bits). writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime module base + 0x0004 76543210 r sres8 smp1 smp0 prs4 prs3 prs2 prs1 prs0 w reset 0 0 0 00101 figure 8-7. atd control register 4 (atdctl4) table 8-6. atdctl4 field descriptions field description 7 sres8 a/d resolution select this bit selects the resolution of a/d conversion results as either 8 or 10 bits. the a/d converter has an accuracy of 10 bits; however, if low resolution is required, the conversion can be speeded up by selecting 8-bit resolution. 0 10-bit resolution 1 8-bit resolution 6? smp[1:0] sample time select these two bits select the length of the second phase of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4-0). the sample time consists of two phases. the ?st phase is two atd conversion clock cycles long and transfers the sample quickly (via the buffer ampli?r) onto the a/d machines storage node. the second phase attaches the external analog signal directly to the storage node for ?al charging and high accuracy. table 8-7 lists the lengths available for the second sample phase. 4? prs[4:0} atd clock prescaler ?these 5 bits are the binary value prescaler value prs. the atd conversion clock frequency is calculated as follows: note: the maximum atd conversion clock frequency is half the bus clock. the default (after reset) prescaler value is 5 which results in a default atd conversion clock frequency that is bus clock divided by 12. table 8-8 illustrates the divide-by operation and the appropriate range of the bus clock. table 8-7. sample time select smp1 smp0 length of 2nd phase of sample time 0 0 2 a/d conversion clock periods 0 1 4 a/d conversion clock periods 1 0 8 a/d conversion clock periods 1 1 16 a/d conversion clock periods atdclock busclock [] prs 1 + [] ----------------------------- - 0.5 =
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 235 rev 1.09 table 8-8. clock prescaler values prescale value total divisor value maximum bus clock (1) 1. maximum atd conversion clock frequency is 2 mhz. the maximum allowed bus clock frequency is shown in this column. minimum bus clock (2) 2. minimum atd conversion clock frequency is 500 khz. the minimum allowed bus clock frequency is shown in this column. 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111 divide by 2 divide by 4 divide by 6 divide by 8 divide by 10 divide by 12 divide by 14 divide by 16 divide by 18 divide by 20 divide by 22 divide by 24 divide by 26 divide by 28 divide by 30 divide by 32 divide by 34 divide by 36 divide by 38 divide by 40 divide by 42 divide by 44 divide by 46 divide by 48 divide by 50 divide by 52 divide by 54 divide by 56 divide by 58 divide by 60 divide by 62 divide by 64 4 mhz 8 mhz 12 mhz 16 mhz 20 mhz 24 mhz 28 mhz 32 mhz 36 mhz 40 mhz 44 mhz 48 mhz 52 mhz 56 mhz 60 mhz 64 mhz 68 mhz 72 mhz 76 mhz 80 mhz 84 mhz 88 mhz 92 mhz 96 mhz 100 mhz 104 mhz 108 mhz 112 mhz 116 mhz 120 mhz 124 mhz 128 mhz 1 mhz 2 mhz 3 mhz 4 mhz 5 mhz 6 mhz 7 mhz 8 mhz 9 mhz 10 mhz 11 mhz 12 mhz 13 mhz 14 mhz 15 mhz 16 mhz 17 mhz 18 mhz 19 mhz 20 mhz 21 mhz 22 mhz 23 mhz 24 mhz 25 mhz 26 mhz 27 mhz 28 mhz 29 mhz 30 mhz 31 mhz 32 mhz
chapter 8 analog-to-digital converter (atd10b8c) block description 236 mc9s12q128 freescale semiconductor rev 1.09 8.3.2.6 atd control register 5 (atdctl5) this register selects the type of conversion sequence and the analog input channels sampled. writes to this register will abort current conversion sequence and start a new conversion sequence. read: anytime write: anytime module base + 0x0005 76543210 r djm dsgn scan mult 0 cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 8-8. atd control register 5 (atdctl5) table 8-9. atdctl5 field descriptions field description 7 djm result register data justi?ation ?this bit controls justi?ation of conversion data in the result registers. see section 8.3.2.13, ?td conversion result registers (atddrhx/atddrlx) for details. 0 left justi?d data in the result registers 1 right justi?d data in the result registers 6 dsgn result register data signed or unsigned representation ?this bit selects between signed and unsigned conversion data representation in the result registers. signed data is represented as 2s complement. signed data is not available in right justi?ation. see section 8.3.2.13, ?td conversion result registers (atddrhx/atddrlx) for details. 0 unsigned data representation in the result registers 1 signed data representation in the result registers table 8-10 summarizes the result data formats available and how they are set up using the control bits. table 8-11 illustrates the difference between the signed and unsigned, left justi?d output codes for an input signal range between 0 and 5.12 volts. 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. 0 single conversion sequence 1 continuous conversion sequences (scan mode) 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code. 0 sample only one channel 1 sample across several channels 2? cc, cb, ca analog input channel select code ?these bits select the analog input channel(s) whose signals are sampled and converted to digital codes. table 8-12 lists the coding used to select the various analog input channels. in the case of single channel scans (mult = 0), this selection code speci?d the channel examined. in the case of multi-channel scans (mult = 1), this selection code represents the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing channel selection code; selection codes that reach the maximum value wrap around to the minimum value.
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 237 rev 1.09 table 8-10. available result data formats sres8 djm dsgn result data formats description and bus bit mapping 1 1 1 0 0 0 0 0 1 0 0 1 0 1 x 0 1 x 8-bit / left justi?d / unsigned ?bits 8?5 8-bit / left justi?d / signed ?bits 8?5 8-bit / right justi?d / unsigned ?bits 0? 10-bit / left justi?d / unsigned ?bits 6?5 10-bit / left justi?d / signed ?bits 6?5 10-bit / right justi?d / unsigned ?bits 0? table 8-11. left justi?d, signed, and unsigned atd output codes. input signal v rl = 0 volts v rh = 5.12 volts signed 8-bit codes unsigned 8-bit codes signed 10-bit codes unsigned 10-bit codes 5.120 volts 5.100 5.080 2.580 2.560 2.540 0.020 0.000 7f 7f 7e 01 00 ff 81 80 ff ff fe 81 80 7f 01 00 7fc0 7f00 7e00 0100 0000 ff00 8100 8000 ffc0 ff00 fe00 8100 8000 7f00 0100 0000 table 8-12. analog input channel select coding cc cb ca analog input channel 000 an0 001 an1 010 an2 011 an3 100 an4 101 an5 110 an6 111 an7
chapter 8 analog-to-digital converter (atd10b8c) block description 238 mc9s12q128 freescale semiconductor rev 1.09 8.3.2.7 atd status register 0 (atdstat0) this read-only register contains the sequence complete ?g, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc2, cc1, cc0)) module base + 0x0006 76543210 r scf 0 etorf fifor 0 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 8-9. atd status register 0 (atdstat0) table 8-13. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan = 1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and read of a result register 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge trigger mode (etrigle = 0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl2, atdctl3 or atdctl4 (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger over run error has occurred 1 external trigger over run error has occurred
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 239 rev 1.09 8.3.2.8 reserved register (atdtest0) read: anytime, returns unpredictable values write: anytime in special modes, unimplemented in normal modes note writing to this registers when in special modes can alter functionality. 4 fifor fifo over run flag ?this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been over written before it has been read (i.e. the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) start a new conversion sequence (write to atdctl5 or external trigger) 0 no over run has occurred 1 an over run condition exists 2? cc[2:0] conversion counter these 3 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. for example, cc2 = 1, cc1 = 1, cc0 = 0 indicates that the result of the current conversion will be in atd result register 6. if in non- fifo mode (fifo = 0) the conversion counter is initialized to zero at the begin and end of the conversion sequence. if in fifo mode (fifo = 1) the register counter is not initialized. the conversion counters wraps around when its maximum value is reached. aborting a conversion or starting a new conversion by write to an atdctl register (atdctl5-2) clears the conversion counter even if fifo=1. module base + 0x0008 76543210 ruuuuuuuu w reset 1 0 0 00000 = unimplemented or reserved figure 8-10. reserved register (atdtest0) table 8-13. atdstat0 field descriptions (continued) field description
chapter 8 analog-to-digital converter (atd10b8c) block description 240 mc9s12q128 freescale semiconductor rev 1.09 8.3.2.9 atd test register 1 (atdtest1) this register contains the sc bit used to enable special channel conversions. read: anytime, returns unpredictable values for bit 7 and bit 6 write: anytime module base + 0x0009 76543210 ruuuuuuu sc w reset 0 0 0 00000 = unimplemented or reserved figure 8-11. atd test register 1 (atdtest1) table 8-14. atdtest1 field descriptions field description 0 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cc, cb, and ca of atdctl5. table 8-15 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled note: always write remaining bits of atdtest1 (bit7 to bit1) zero when writing sc bit. not doing so might result in unpredictable atd behavior. table 8-15. special channel select coding sc cc cb ca analog input channel 1 0 x x reserved 1100 v rh 1101 v rl 1110 (v rh +v rl ) / 2 1 1 1 1 reserved
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 241 rev 1.09 8.3.2.10 atd status register 1 (atdstat1) this read-only register contains the conversion complete flags. read: anytime write: anytime, no effect module base + 0x000b 76543210 r ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 w reset 0 0 0 00000 = unimplemented or reserved figure 8-12. atd status register 1 (atdstat1) table 8-16. atdstat1 field descriptions field description 7? ccf[7:0] conversion complete flag x (x = 7, 6, 5, 4, 3, 2, 1, 0) a conversion complete ?g is set at the end of each conversion in a conversion sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore, ccf0 is set when the ?st conversion in a sequence is complete and the result is available in result register atddr0; ccf1 is set when the second conversion in a sequence is complete and the result is available in atddr1, and so forth. a ?g ccfx (x = 7, 6, 5, 4, 3, 2, 1, 0) is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc = 0 and read of atdstat1 followed by read of result register atddrx c) if affc = 1 and read of result register atddrx 0 conversion number x not completed 1 conversion number x has completed, result ready in atddrx
chapter 8 analog-to-digital converter (atd10b8c) block description 242 mc9s12q128 freescale semiconductor rev 1.09 8.3.2.11 atd input enable register (atddien) read: anytime write: anytime module base + 0x000d 76543210 r ien7 ien6 ien5 ien4 ien3 ien2 ien1 ien0 w reset 0 0 0 00000 figure 8-13. atd input enable register (atddien) table 8-17. atddien field descriptions field description 7? ien[7:0] atd digital input enable on channel x (x = 7, 6, 5, 4, 3, 2, 1, 0) this bit controls the digital input buffer from the analog input pin (anx) to ptadx data register. 0 disable digital input buffer to ptadx 1 enable digital input buffer to ptadx. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region.
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 243 rev 1.09 8.3.2.12 port data register (portad) the data port associated with the atd is general purpose i/o. the port pins are shared with the analog a/d inputs an7?n0. read: anytime write: anytime, no effect the a/d input channels may be used for general-purpose digital i/0. 8.3.2.13 atd conversion result registers (atddrhx/atddrlx) the a/d conversion results are stored in 8 read-only result registers atddrhx/atddrlx. the result data is formatted in the result registers based on two criteria. first there is left and right justi?ation; this selection is made using the djm control bit in atdctl5. second there is signed and unsigned data; this selection is made using the dsgn control bit in atdctl5. signed data is stored in 2s complement format and only exists in left justi?d format. signed data selected for right justi?d format is ignored. read: anytime write: anytime, no effect in normal modes module base + 0x000f 76543210 r ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 w reset 1 1 1 11111 pin function an7 an6 an5 an4 an3 an2 an1 an0 = unimplemented or reserved figure 8-14. port data register (portad) table 8-18. portad field descriptions field description 7 ptad[7:0] a/d channel x (anx) digital input (x = 7, 6, 5, 4, 3, 2, 1, 0) if the digital input buffer on the anx pin is enabled (ienx = 1) read returns the logic level on anx pin (signal potentials not meeting v il or v ih speci?ations will have an indeterminate value)). if the digital input buffers are disabled (ienx = 0), read returns a ?? reset sets all portad bits to ??
chapter 8 analog-to-digital converter (atd10b8c) block description 244 mc9s12q128 freescale semiconductor rev 1.09 8.3.2.13.1 left justi?d result data 8.3.2.13.2 right justi?d result data module base + 0x0010 = atddr0h, 0x0012 = atddr1h, 0x0014 = atddr2h, 0x0016 = atddr3h 0x0018 = atddr4h, 0x001a = atddr5h, 0x001c = atddr6h, 0x001e = atddr7h 76543210 r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 10-bit data 8-bit data w reset 0 0 0 0 0 0 0 0 figure 8-15. left justi?d, atd conversion result register, high byte (atddrxh) module base + 0x0011 = atddr0l, 0x0013 = atddr1l, 0x0015 = atddr2l, 0x0017 = atddr3l 0x0019 = atddr4l, 0x001b = atddr5l, 0x001d = atddr6l, 0x001f = atddr7l 76543210 r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 10-bit data 8-bit data w reset 0 0 0 0 0 0 0 0 figure 8-16. left justi?d, atd conversion result register, low byte (atddrxl) module base + 0x0010 = atddr0h, 0x0012 = atddr1h, 0x0014 = atddr2h, 0x0016 = atddr3h 0x0018 = atddr4h, 0x001a = atddr5h, 0x001c = atddr6h, 0x001e = atddr7h 76543210 r 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 10-bit data 8-bit data w reset 0 0 0 0 0 0 0 0 figure 8-17. right justi?d, atd conversion result register, high byte (atddrxh) module base + 0x0011 = atddr0l, 0x0013 = atddr1l, 0x0015 = atddr2l, 0x0017 = atddr3l 0x0019 = atddr4l, 0x001b = atddr5l, 0x001d = atddr6l, 0x001f = atddr7l 76543210 r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 10-bit data 8-bit data w reset 0 0 0 0 0 0 0 0 figure 8-18. right justi?d, atd conversion result register, low byte (atddrxl)
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 245 rev 1.09 8.4 functional description the atd10b8c is structured in an analog and a digital sub-block. 8.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies v dda and v ssa allow to isolate noise of other mcu circuitry from the analog sub-block. 8.4.1.1 sample and hold machine the sample and hold (s/h) machine accepts analog signals from the external surroundings and stores them as capacitor charge on a storage node. the sample process uses a two stage approach. during the ?st stage, the sample ampli?r is used to quickly charge the storage node.the second stage connects the input directly to the storage node to complete the sample for high accuracy. when not sampling, the sample and hold machine disables its own clocks. the analog electronics still draw their quiescent current. the power down (adpu) bit must be set to disable both the digital clocks and the analog power consumption. the input analog signals are unipolar and must fall within the potential range of v ssa to v dda . 8.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 8 external analog input channels to the sample and hold machine. 8.4.1.3 sample buffer ampli?r the sample ampli?r is used to buffer the input analog signal so that the storage node can be quickly charged to the sample potential. 8.4.1.4 analog-to-digital (a/d) machine the a/d machine performs analog-to-digital conversions. the resolution is program selectable at either 8 or 10 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the stored analog sample potential with a series of digitally generated analog potentials. by following a binary search algorithm, the a/d machine locates the approximating potential that is nearest to the sampled potential. when not converting the a/d machine disables its own clocks. the analog electronics still draws quiescent current. the power down (adpu) bit must be set to disable both the digital clocks and the analog power consumption. only analog input signals within the potential range of v rl to v rh (a/d reference potentials) will result in a non-railed digital output codes.
chapter 8 analog-to-digital converter (atd10b8c) block description 246 mc9s12q128 freescale semiconductor rev 1.09 8.4.2 digital sub-block this subsection explains some of the digital features in more detail. see 7 for all details. 8.4.2.1 external trigger input (etrig) the external trigger feature allows the user to synchronize atd conversions to the external environment events rather than relying on software to signal the atd module when atd conversions are to take place. the input signal (atd channel 7) is programmable to be edge or level sensitive with polarity control. table 8-19 gives a brief description of the different combinations of control bits and their affect on the external trigger function . during a conversion, if additional active edges are detected the overrun error ?g etorf is set. in either level or edge triggered modes, the ?st conversion begins when the trigger is received. in both cases, the maximum latency time is one bus clock cycle plus any skew or delay introduced by the trigger circuitry. note the conversion results for the external trigger atd channel 7 have no meaning while external trigger mode is enabled. once etrige is enabled, conversions cannot be started by a write to atdctl5, but rather must be triggered externally. if the level mode is active and the external trigger both de-asserts and re-asserts itself during a conversion sequence, this does not constitute an overrun; therefore, the ?g is not set. if the trigger is left asserted in level mode while a sequence is completing, another sequence will be triggered immediately. table 8-19. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x falling edge triggered. performs one conversion sequence per trigger. 0 1 1 x rising edge triggered. performs one conversion sequence per trigger. 1 0 1 x trigger active low. performs continuous conversions while trigger is active. 1 1 1 x trigger active high. performs continuous conversions while trigger is active.
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 247 rev 1.09 8.4.2.2 general-purpose digital port operation the channel pins can be multiplexed between analog and digital data. as analog inputs, they are multiplexed and sampled to supply signals to the a/d converter. alternatively they can be con?ured as digital i/o signals with the port i/o data being held in portad. the analog/digital multiplex operation is performed in the pads. the pad is always connected to the analog inputs of the atd10b8c. the pad signal is buffered to the digital port registers. this buffer can be turned on or off with the atddien register. this is important so that the buffer does not draw excess current when analog potentials are presented at its input. 8.4.2.3 low-power modes the atd10b8c can be con?ured for lower mcu power consumption in three different ways: 1. stop mode: this halts a/d conversion. exit from stop mode will resume a/d conversion, but due to the recovery time the result of this conversion should be ignored. 2. wait mode with awai = 1: this halts a/d conversion. exit from wait mode will resume a/d conversion, but due to the recovery time the result of this conversion should be ignored. 3. writing adpu = 0 (note that all atd registers remain accessible.): this aborts any a/d conversion in progress. note the reset value for the adpu bit is zero. therefore, when this module is reset, it is reset into the power down state. 8.5 initialization/application information 8.5.1 setting up and starting an a/d conversion the following describes a typical setup procedure for starting a/d conversions. it is highly recommended to follow this procedure to avoid common mistakes. each step of the procedure will have a general remark and a typical example 8.5.1.1 step 1 power up the atd and concurrently de?e other settings in atdctl2 example: write to atdctl2: adpu=1 -> powers up the atd, ascie=1 enable interrupt on ?ish of a conversion sequence. 8.5.1.2 step 2 wait for the atd recovery time t rec before you proceed with step 3. example: use the cpu in a branch loop to wait for a de?ed number of bus clocks.
chapter 8 analog-to-digital converter (atd10b8c) block description 248 mc9s12q128 freescale semiconductor rev 1.09 8.5.1.3 step 3 con?ure how many conversions you want to perform in one sequence and de?e other settings in atdctl3. example: write s4c=1 to do 4 conversions per sequence. 8.5.1.4 step 4 con?ure resolution, sampling time and atd clock speed in atdctl4. example: use default for resolution and sampling time by leaving sres8, smp1 and smp0 clear. for a bus clock of 40mhz write 9 to pr4-0, this gives an atd clock of 0.5*40mhz/(9+1) = 2mhz which is within the allowed range for f atdclk . 8.5.1.5 step 5 con?ure starting channel, single/multiple channel, continuous or single sequence and result data format in atdctl5. writing atdctl5 will start the conversion, so make sure your write atdctl5 in the last step. example: leave cc,cb,ca clear to start on channel an0. write mult=1 to convert channel an0 to an3 in a sequence (4 conversion per sequence selected in atdctl3). 8.5.2 aborting an a/d conversion 8.5.2.1 step 1 disable the atd interrupt by writing ascie=0 in atdctl2. this will also abort any ongoing conversion sequence. it is important to clear the interrupt enable at this point, prior to step 3, as depending on the device clock gating it may not always be possible to clear it or the scf ?g once the module is disabled (adpu=0). 8.5.2.2 step 2 clear the scf ?g by writing a 1 in atdstat0. (remaining ?gs will be cleared with the next start of a conversions, but scf ?g should be cleared to avoid scf interrupt.) 8.5.2.3 step 3 power down atd by writing adpu=0 in atdctl2. 8.6 resets at reset the atd10b8c is in a power down state. the reset state of each individual bit is listed within section 8.3.2, ?egister descriptions which details the registers and their bit-?ld.
chapter 8 analog-to-digital converter (atd10b8c) block description freescale semiconductor mc9s12q128 249 rev 1.09 8.7 interrupts the interrupt requested by the atd10b8c is listed in table 8-20 . refer to mcu speci?ation for related vector address and priority. see section 8.3.2, ?egister descriptions for further details. table 8-20. atd10b8c interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2
chapter 8 analog-to-digital converter (atd10b8c) block description 250 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 251 rev 1.09 chapter 9 clocks and reset generator (crgv4) block description 9.1 introduction this speci?ation describes the function of the clocks and reset generator (crgv4). 9.1.1 features the main features of this block are: phase-locked loop (pll) frequency multiplier reference divider automatic bandwidth control mode for low-jitter operation automatic frequency lock detector cpu interrupt on entry or exit from locked condition self-clock mode in absence of reference clock system clock generator clock quality check clock switch for either oscillator- or pll-based system clocks user selectable disabling of clocks during wait mode for reduced power consumption computer operating properly (cop) watchdog timer with time-out clear window system reset generation from the following possible sources: power-on reset low voltage reset refer to the device overview section for availability of this feature. cop reset loss of clock reset external pin reset real-time interrupt (rti)
chapter 9 clocks and reset generator (crgv4) block description 252 mc9s12q128 freescale semiconductor rev 1.09 9.1.2 modes of operation this subsection lists and brie? describes all operating modes supported by the crg. run mode all functional parts of the crg are running during normal run mode. if rti or cop functionality is required the individual bits of the associated rate select registers (copctl, rtictl) have to be set to a nonzero value. wait mode this mode allows to disable the system and core clocks depending on the con?uration of the individual bits in the clksel register. stop mode depending on the setting of the pstp bit, stop mode can be differentiated between full stop mode (pstp = 0) and pseudo-stop mode (pstp = 1). full stop mode the oscillator is disabled and thus all system and core clocks are stopped. the cop and the rti remain frozen. pseudo-stop mode the oscillator continues to run and most of the system and core clocks are stopped. if the respective enable bits are set the cop and rti will continue to run, else they remain frozen. self-clock mode self-clock mode will be entered if the clock monitor enable bit (cme) and the self-clock mode enable bit (scme) are both asserted and the clock monitor in the oscillator block detects a loss of clock. as soon as self-clock mode is entered the crgv4 starts to perform a clock quality check. self-clock mode remains active until the clock quality check indicates that the required quality of the incoming clock signal is met (frequency and amplitude). self-clock mode should be used for safety purposes only. it provides reduced functionality to the mcu in case a loss of clock is causing severe system conditions. 9.1.3 block diagram figure 9-1 shows a block diagram of the crgv4.
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 253 rev 1.09 figure 9-1. crg block diagram 9.2 external signal description this section lists and describes the signals that connect off chip. 9.2.1 v ddpll , v sspll ?pll operating voltage, pll ground these pins provides operating voltage (v ddpll ) and ground (v sspll ) for the pll circuitry. this allows the supply voltage to the pll to be independently bypassed. even if pll usage is not required v ddpll and v sspll must be connected properly. 9.2.2 xfc ?pll loop filter pin a passive external loop ?ter must be placed on the xfc pin. the ?ter is a second-order, low-pass ?ter to eliminate the vco input ripple. the value of the external ?ter network and the reference frequency determines the speed of the corrections and the stability of the pll. refer to the device overview chapter for calculation of pll loop ?ter (xfc) components. if pll usage is not required the xfc pin must be tied to v ddpll . crg registers clock and reset cop reset rti pll xfc v ddpll v sspll oscil- extal xtal control bus clock system reset oscillator clock pllclk oscclk core clock clock monitor cm fail clock quality checker reset generator xclks power-on reset low voltage reset 1 cop timeout real-time interrupt pll lock interrupt self-clock mode interrupt lator voltage regulator 1 refer to the device overview section for availability of the low-voltage reset feature.
chapter 9 clocks and reset generator (crgv4) block description 254 mc9s12q128 freescale semiconductor rev 1.09 figure 9-2. pll loop filter connections 9.2.3 reset ?reset pin reset is an active low bidirectional reset pin. as an input it initializes the mcu asynchronously to a known start-up state. as an open-drain output it indicates that an system reset (internal to mcu) has been triggered. 9.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the crgv4. 9.3.1 module memory map table 9-1 gives an overview on all crgv4 registers. table 9-1. crgv4 memory map address offset use access 0x0000 crg synthesizer register (synr) r/w 0x0001 crg reference divider register (refdv) r/w 0x0002 crg test flags register (ctflg) (1) 1. ctflg is intended for factory test purposes only. r/w 0x0003 crg flags register (crgflg) r/w 0x0004 crg interrupt enable register (crgint) r/w 0x0005 crg clock select register (clksel) r/w 0x0006 crg pll control register (pllctl) r/w 0x0007 crg rti control register (rtictl) r/w 0x0008 crg cop control register (copctl) r/w 0x0009 crg force and bypass test register (forbyp) (2) 2. forbyp is intended for factory test purposes only. r/w 0x000a crg test control register (ctctl) (3) 3. ctctl is intended for factory test purposes only. r/w 0x000b crg cop arm/timer reset (armcop) r/w mcu xfc rs cs v ddpll cp
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 255 rev 1.09 note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. 9.3.2 register descriptions this section describes in address order all the crgv4 registers and their individual bits. register name bit 7 654321 bit 0 0x0000 synr r0 0 syn5 syn4 syn3 syn2 syn1 syn0 w 0x0001 refdv r0000 refdv3 refdv2 refdv1 refdv0 w 0x0002 ctflg r00000000 w 0x0003 crgflg r rtif porf lvrf lockif lock track scmif scm w 0x0004 crgint r rtie 00 lockie 00 scmie 0 w 0x0005 clksel r pllsel pstp syswai roawai pllwai cwai rtiwai copwai w 0x0006 pllctl r cme pllon auto acq 0 pre pce scme w 0x0007 rtictl r0 rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 w 0x0008 copctl r wcop rsbck 000 cr2 cr1 cr0 w 0x0009 forbyp r00000000 w 0x000a ctctl r00000000 w = unimplemented or reserved figure 9-3. crg register summary
chapter 9 clocks and reset generator (crgv4) block description 256 mc9s12q128 freescale semiconductor rev 1.09 9.3.2.1 crg synthesizer register (synr) the synr register controls the multiplication factor of the pll. if the pll is on, the count in the loop divider (synr) register effectively multiplies up the pll clock (pllclk) from the reference frequency by 2 x (synr+1). pllclk will not be below the minimum vco frequency (f scm ). note if pll is selected (pllsel=1), bus clock = pllclk / 2 bus clock must not exceed the maximum operating system frequency. read: anytime write: anytime except if pllsel = 1 note write to this register initializes the lock detector bit and the track detector bit. 0x000b armcop r00000000 w bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 module base + 0x0000 76543210 r0 0 syn5 synr syn3 syn2 syn1 syn0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-4. crg synthesizer register (synr) register name bit 7 654321 bit 0 = unimplemented or reserved figure 9-3. crg register summary (continued) pllclk 2xoscclkx synr 1 + () refdv 1 + () --------------------------------- - =
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 257 rev 1.09 9.3.2.2 crg reference divider register (refdv) the refdv register provides a ?er granularity for the pll multiplier steps. the count in the reference divider divides oscclk frequency by refdv + 1. read: anytime write: anytime except when pllsel = 1 note write to this register initializes the lock detector bit and the track detector bit. 9.3.2.3 reserved register (ctflg) this register is reserved for factory testing of the crgv4 module and is not available in normal modes. read: always reads 0x0000 in normal modes write: unimplemented in normal modes note writing to this register when in special mode can alter the crgv4 functionality. module base + 0x0001 76543210 r0000 refdv3 refdv2 refdv1 refdv0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-5. crg reference divider register (refdv) module base + 0x0002 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 9-6. crg reserved register (ctflg)
chapter 9 clocks and reset generator (crgv4) block description 258 mc9s12q128 freescale semiconductor rev 1.09 9.3.2.4 crg flags register (crgflg) this register provides crg status bits and ?gs. read: anytime write: refer to each bit for individual write conditions module base + 0x0003 76543210 r rtif porf lvrf lockif lock track scmif scm w reset 0 note 1 note 2 00000 1. porf is set to 1 when a power-on reset occurs. unaffected by system reset. 2. lvrf is set to 1 when a low-voltage reset occurs. unaffected by system reset. = unimplemented or reserved figure 9-7. crg flag register (crgflg) table 9-2. crgflg field descriptions field description 7 rtif real-time interrupt flag rtif is set to 1 at the end of the rti period. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (rtie = 1), rtif causes an interrupt request. 0 rti time-out has not yet occurred. 1 rti time-out has occurred. 6 porf power-on reset flag porf is set to 1 when a power-on reset occurs. this ?g can only be cleared by writing a 1. writing a 0 has no effect. 0 power-on reset has not occurred. 1 power-on reset has occurred. 5 lvrf low-voltage reset flag if low voltage reset feature is not available (see the device overview chapter), lvrf always reads 0. lvrf is set to 1 when a low voltage reset occurs. this ?g can only be cleared by writing a 1. writing a 0 has no effect. 0 low voltage reset has not occurred. 1 low voltage reset has occurred. 4 lockif pll lock interrupt flag lockif is set to 1 when lock status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect.if enabled (lockie = 1), lockif causes an interrupt request. 0 no change in lock bit. 1 lock bit has changed. 3 lock lock status bit lock re?cts the current state of pll lock condition. this bit is cleared in self-clock mode. writes have no effect. 0 pll vco is not within the desired tolerance of the target frequency. 1 pll vco is within the desired tolerance of the target frequency. 2 track track status bit track re?cts the current state of pll track condition. this bit is cleared in self-clock mode. writes have no effect. 0 acquisition mode status. 1 tracking mode status.
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 259 rev 1.09 9.3.2.5 crg interrupt enable register (crgint) this register enables crg interrupt requests. read: anytime write: anytime 1 scmif self-clock mode interrupt flag ?scmif is set to 1 when scm status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (scmie=1), scmif causes an interrupt request. 0 no change in scm bit. 1 scm bit has changed. 0 scm self-clock mode status bit ?scm re?cts the current clocking mode. writes have no effect. 0 mcu is operating normally with oscclk available. 1 mcu is operating in self-clock mode with oscclk in an unknown state. all clocks are derived from pllclk running at its minimum frequency f scm . module base + 0x0004 76543210 r rtie 00 lockie 00 scmie 0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-8. crg interrupt enable register (crgint) table 9-3. crgint field descriptions field description 7 rtie real-time interrupt enable bit 0 interrupt requests from rti are disabled. 1 interrupt will be requested whenever rtif is set. 4 lockie lock interrupt enable bit 0 lock interrupt requests are disabled. 1 interrupt will be requested whenever lockif is set. 1 scmie self-clock mode interrupt enable bit 0 scm interrupt requests are disabled. 1 interrupt will be requested whenever scmif is set. table 9-2. crgflg field descriptions (continued) field description
chapter 9 clocks and reset generator (crgv4) block description 260 mc9s12q128 freescale semiconductor rev 1.09 9.3.2.6 crg clock select register (clksel) this register controls crg clock selection. refer to figure 9-17 for details on the effect of each bit. read: anytime write: refer to each bit for individual write conditions module base + 0x0005 76543210 r pllsel pstp syswai roawai pllwai cwai rtiwai copwai w reset 0 0 0 00000 figure 9-9. crg clock select register (clksel) table 9-4. clksel field descriptions field description 7 pllsel pll select bit write anytime. writing a 1 when lock = 0 and auto = 1, or track = 0 and auto = 0 has no effect. this prevents the selection of an unstable pllclk as sysclk. pllsel bit is cleared when the mcu enters self-clock mode, stop mode or wait mode with pllwai bit set. 0 system clocks are derived from oscclk (bus clock = oscclk / 2). 1 system clocks are derived from pllclk (bus clock = pllclk / 2). 6 pstp pseudo-stop bit ?write: anytime ?this bit controls the functionality of the oscillator during stop mode. 0 oscillator is disabled in stop mode. 1 oscillator continues to run in stop mode (pseudo-stop). the oscillator amplitude is reduced. refer to oscillator block description for availability of a reduced oscillator amplitude. note: pseudo-stop allows for faster stop recovery and reduces the mechanical stress and aging of the resonator in case of frequent stop conditions at the expense of a slightly increased power consumption. note: lower oscillator amplitude exhibits lower power consumption but could have adverse effects during any electro-magnetic susceptibility (ems) tests. 5 syswai system clocks stop in wait mode bit ?write: anytime 0 in wait mode, the system clocks continue to run. 1 in wait mode, the system clocks stop. note: rti and cop are not affected by syswai bit. 4 roawai reduced oscillator amplitude in wait mode bit ?write: anytime ?refer to oscillator block description chapter for availability of a reduced oscillator amplitude. if no such feature exists in the oscillator block then setting this bit to 1 will not have any effect on power consumption. 0 normal oscillator amplitude in wait mode. 1 reduced oscillator amplitude in wait mode. note: lower oscillator amplitude exhibits lower power consumption but could have adverse effects during any electro-magnetic susceptibility (ems) tests. 3 pllwai pll stops in wait mode bit write: anytime if pllwai is set, the crgv4 will clear the pllsel bit before entering wait mode. the pllon bit remains set during wait mode but the pll is powered down. upon exiting wait mode, the pllsel bit has to be set manually if pll clock is required. while the pllwai bit is set the auto bit is set to 1 in order to allow the pll to automatically lock on the selected target frequency after exiting wait mode. 0 pll keeps running in wait mode. 1 pll stops in wait mode.
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 261 rev 1.09 9.3.2.7 crg pll control register (pllctl) this register controls the pll functionality. read: anytime write: refer to each bit for individual write conditions 2 cwai core stops in wait mode bit ?write: anytime 0 core clock keeps running in wait mode. 1 core clock stops in wait mode. 1 rtiwai rti stops in wait mode bit ?write: anytime 0 rti keeps running in wait mode. 1 rti stops and initializes the rti dividers whenever the part goes into wait mode. 0 copwai cop stops in wait mode bit ?normal modes: write once ?pecial modes: write anytime 0 cop keeps running in wait mode. 1 cop stops and initializes the cop dividers whenever the part goes into wait mode. module base + 0x0006 76543210 r cme pllon auto acq 0 pre pce scme w reset 1 1 1 10001 = unimplemented or reserved figure 9-10. crg pll control register (pllctl) table 9-5. pllctl field descriptions field description 7 cme clock monitor enable bit ?cme enables the clock monitor. write anytime except when scm = 1. 0 clock monitor is disabled. 1 clock monitor is enabled. slow or stopped clocks will cause a clock monitor reset sequence or self-clock mode. note: operating with cme = 0 will not detect any loss of clock. in case of poor clock quality this could cause unpredictable operation of the mcu. note: in stop mode (pstp = 0) the clock monitor is disabled independently of the cme bit setting and any loss of clock will not be detected. 6 pllon phase lock loop on bit pllon turns on the pll circuitry. in self-clock mode, the pll is turned on, but the pllon bit reads the last latched value. write anytime except when pllsel = 1. 0 pll is turned off. 1 pll is turned on. if auto bit is set, the pll will lock automatically. table 9-4. clksel field descriptions (continued) field description
chapter 9 clocks and reset generator (crgv4) block description 262 mc9s12q128 freescale semiconductor rev 1.09 9.3.2.8 crg rti control register (rtictl) this register selects the timeout period for the real-time interrupt. read: anytime write: anytime note a write to this register initializes the rti counter. 5 auto automatic bandwidth control bit ?auto selects either the high bandwidth (acquisition) mode or the low bandwidth (tracking) mode depending on how close to the desired frequency the vco is running. write anytime except when pllwai=1, because pllwai sets the auto bit to 1. 0 automatic mode control is disabled and the pll is under software control, using acq bit. 1 automatic mode control is enabled and acq bit has no effect. 4 acq acquisition bit ?write anytime. if auto=1 this bit has no effect. 0 low bandwidth ?ter is selected. 1 high bandwidth ?ter is selected. 2 pre rti enable during pseudo-stop bit ?pre enables the rti during pseudo-stop mode. write anytime. 0 rti stops running during pseudo-stop mode. 1 rti continues running during pseudo-stop mode. note: if the pre bit is cleared the rti dividers will go static while pseudo-stop mode is active. the rti dividers will not initialize like in wait mode with rtiwai bit set. 1 pce cop enable during pseudo-stop bit ?pce enables the cop during pseudo-stop mode. write anytime. 0 cop stops running during pseudo-stop mode 1 cop continues running during pseudo-stop mode note: if the pce bit is cleared the cop dividers will go static while pseudo-stop mode is active. the cop dividers will not initialize like in wait mode with copwai bit set. 0 scme self-clock mode enable bit normal modes: write once ?pecial modes: write anytime scme can not be cleared while operating in self-clock mode (scm=1). 0 detection of crystal clock failure causes clock monitor reset (see section 9.5.1, ?lock monitor reset ?. 1 detection of crystal clock failure forces the mcu in self-clock mode (see section 9.4.7.2, ?elf-clock mode ?. module base + 0x0007 76543210 r0 rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-11. crg rti control register (rtictl) table 9-5. pllctl field descriptions (continued) field description
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 263 rev 1.09 table 9-6. rtictl field descriptions field description 6:4 rtr[6:4] real-time interrupt prescale rate select bits these bits select the prescale rate for the rti. see table 9-7 . 3:0 rtr[3:0] real-time interrupt modulus counter select bits ?these bits select the modulus counter target value to provide additional granularity. table 9-7 shows all possible divide values selectable by the rtictl register. the source clock for the rti is oscclk. table 9-7. rti frequency divide rates rtr[3:0] rtr[6:4] = 000 (off) 001 (2 10 ) 010 (2 11 ) 011 (2 12 ) 100 (2 13 ) 101 (2 14 ) 110 (2 15 ) 111 (2 16 ) 0000 ( 1) off * 2 10 2 11 2 12 2 13 2 14 2 15 2 16 0001 ( 2) off * 2x2 10 2x2 11 2x2 12 2x2 13 2x2 14 2x2 15 2x2 16 0010 ( 3) off * 3x2 10 3x2 11 3x2 12 3x2 13 3x2 14 3x2 15 3x2 16 0011 ( 4) off * 4x2 10 4x2 11 4x2 12 4x2 13 4x2 14 4x2 15 4x2 16 0100 ( 5) off * 5x2 10 5x2 11 5x2 12 5x2 13 5x2 14 5x2 15 5x2 16 0101 ( 6) off * 6x2 10 6x2 11 6x2 12 6x2 13 6x2 14 6x2 15 6x2 16 0110 ( 7) off * 7x2 10 7x2 11 7x2 12 7x2 13 7x2 14 7x2 15 7x2 16 0111 ( 8) off * 8x2 10 8x2 11 8x2 12 8x2 13 8x2 14 8x2 15 8x2 16 1000 ( 9) off * 9x2 10 9x2 11 9x2 12 9x2 13 9x2 14 9x2 15 9x2 16 1001 ( 10) off * 10x2 10 10x2 11 10x2 12 10x2 13 10x2 14 10x2 15 10x2 16 1010 ( 11) off * 11x2 10 11x2 11 11x2 12 11x2 13 11x2 14 11x2 15 11x2 16 1011 ( 12) off * 12x2 10 12x2 11 12x2 12 12x2 13 12x2 14 12x2 15 12x2 16 1100 ( 13) off * 13x2 10 13x2 11 13x2 12 13x2 13 13x2 14 13x2 15 13x2 16 1101 ( 14) off * 14x2 10 14x2 11 14x2 12 14x2 13 14x2 14 14x2 15 14x2 16 1110 ( 15) off * 15x2 10 15x2 11 15x2 12 15x2 13 15x2 14 15x2 15 15x2 16 1111 ( 16) off * 16x2 10 16x2 11 16x2 12 16x2 13 16x2 14 16x2 15 16x2 16 * denotes the default value out of reset.this value should be used to disable the rti to ensure future backwards compatibility.
chapter 9 clocks and reset generator (crgv4) block description 264 mc9s12q128 freescale semiconductor rev 1.09 9.3.2.9 crg cop control register (copctl) this register controls the cop (computer operating properly) watchdog. read: anytime write: wcop, cr2, cr1, cr0: once in user mode, anytime in special mode write: rsbck: once module base + 0x0008 76543210 r wcop rsbck 000 cr2 cr1 cr0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-12. crg cop control register (copctl) table 9-8. copctl field descriptions field description 7 wcop window cop mode bit when set, a write to the armcop register must occur in the last 25% of the selected period. a write during the ?st 75% of the selected period will reset the part. as long as all writes occur during this window, 0x0055 can be written as often as desired. as soon as 0x00aa is written after the 0x0055, the time- out logic restarts and the user must wait until the next window before writing to armcop. table 9-9 shows the exact duration of this window for the seven available cop rates. 0 normal cop operation 1 window cop operation 6 rsbck cop and rti stop in active bdm mode bit 0 allows the cop and rti to keep running in active bdm mode. 1 stops the cop and rti counters whenever the part is in active bdm mode. 2:0 cr[2:0] cop watchdog timer rate select these bits select the cop time-out rate (see table 9-9 ). the cop time- out period is oscclk period divided by cr[2:0] value. writing a nonzero value to cr[2:0] enables the cop counter and starts the time-out period. a cop counter time-out causes a system reset. this can be avoided by periodically (before time-out) reinitializing the cop counter via the armcop register . table 9-9. cop watchdog rates (1) 1. oscclk cycles are referenced from the previous cop time-out reset (writing 0x0055/0x00aa to the armcop register) cr2 cr1 cr0 oscclk cycles to time out 0 0 0 cop disabled 001 2 14 010 2 16 011 2 18 100 2 20 101 2 22 110 2 23 111 2 24
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 265 rev 1.09 9.3.2.10 reserved register (forbyp) note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special modes can alter the crgs functionality. read: always read 0x0000 except in special modes write: only in special modes 9.3.2.11 reserved register (ctctl) note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special test modes can alter the crgs functionality. read: always read 0x0080 except in special modes write: only in special modes module base + 0x0009 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 9-13. reserved register (forbyp) module base + 0x000a 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 9-14. reserved register (ctctl)
chapter 9 clocks and reset generator (crgv4) block description 266 mc9s12q128 freescale semiconductor rev 1.09 9.3.2.12 crg cop timer arm/reset register (armcop) this register is used to restart the cop time-out period. read: always reads 0x0000 write: anytime when the cop is disabled (cr[2:0] = ?00? writing to this register has no effect. when the cop is enabled by setting cr[2:0] nonzero, the following applies: writing any value other than 0x0055 or 0x00aa causes a cop reset. to restart the cop time-out period you must write 0x0055 followed by a write of 0x00aa. other instructions may be executed between these writes but the sequence (0x0055, 0x00aa) must be completed prior to cop end of time-out period to avoid a cop reset. sequences of 0x0055 writes or sequences of 0x00aa writes are allowed. when the wcop bit is set, 0x0055 and 0x00aa writes must be done in the last 25% of the selected time-out period; writing any value in the ?st 75% of the selected period will cause a cop reset. 9.4 functional description this section gives detailed informations on the internal operation of the design. 9.4.1 phase locked loop (pll) the pll is used to run the mcu from a different time base than the incoming oscclk. for increased ?xibility, oscclk can be divided in a range of 1 to 16 to generate the reference frequency. this offers a ?er multiplication granularity. the pll can multiply this reference clock by a multiple of 2, 4, 6,... 126,128 based on the synr register. caution although it is possible to set the two dividers to command a very high clock frequency, do not exceed the speci?d bus frequency limit for the mcu. if (pllsel = 1), bus clock = pllclk / 2 module base + 0x000b 76543210 r00000000 w bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset 0 0 0 00000 figure 9-15. armcop register diagram pllclk 2 oscclk synr 1 + [] refdv 1 + [] --------------------------------- - =
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 267 rev 1.09 the pll is a frequency generator that operates in either acquisition mode or tracking mode, depending on the difference between the output frequency and the target frequency. the pll can change between acquisition and tracking modes either automatically or manually. the vco has a minimum operating frequency, which corresponds to the self-clock mode frequency f scm . figure 9-16. pll functional diagram 9.4.1.1 pll operation the oscillator output clock signal (oscclk) is fed through the reference programmable divider and is divided in a range of 1 to 16 (refdv+1) to output the reference clock. the vco output clock, (pllclk) is fed back through the programmable loop divider and is divided in a range of 2 to 128 in increments of [2 x (synr +1)] to output the feedback clock. see figure 9-16 . the phase detector then compares the feedback clock, with the reference clock. correction pulses are generated based on the phase difference between the two signals. the loop ?ter then slightly alters the dc voltage on the external ?ter capacitor connected to xfc pin, based on the width and direction of the correction pulse. the ?ter can make fast or slow corrections depending on its mode, as described in the next subsection. the values of the external ?ter network and the reference frequency determine the speed of the corrections and the stability of the pll. 9.4.1.2 acquisition and tracking modes the lock detector compares the frequencies of the feedback clock, and the reference clock. therefore, the speed of the lock detector is directly proportional to the ?al reference frequency. the circuit determines the mode of the pll and the lock condition based on this comparison. reduced consumption oscillator extal xtal oscclk pllclk reference programmable divider pdet phase detector refdv <3:0> loop programmable divider syn <5:0> cpump vco lock loop filter xfc pin up down lock detector reference feedback vddpll vddpll/vsspll crystal monitor vddpll/vsspll vdd/vss supplied by:
chapter 9 clocks and reset generator (crgv4) block description 268 mc9s12q128 freescale semiconductor rev 1.09 the pll ?ter can be manually or automatically con?ured into one of two possible operating modes: acquisition mode in acquisition mode, the ?ter can make large frequency corrections to the vco. this mode is used at pll start-up or when the pll has suffered a severe noise hit and the vco frequency is far off the desired frequency. when in acquisition mode, the track status bit is cleared in the crgflg register. tracking mode in tracking mode, the ?ter makes only small corrections to the frequency of the vco. pll jitter is much lower in tracking mode, but the response to noise is also slower. the pll enters tracking mode when the vco frequency is nearly correct and the track bit is set in the crgflg register. the pll can change the bandwidth or operational mode of the loop ?ter manually or automatically. in automatic bandwidth control mode (auto = 1), the lock detector automatically switches between acquisition and tracking modes. automatic bandwidth control mode also is used to determine when the pll clock (pllclk) is safe to use as the source for the system and core clocks. if pll lock interrupt requests are enabled, the software can wait for an interrupt request and then check the lock bit. if cpu interrupts are disabled, software can poll the lock bit continuously (during pll start-up, usually) or at periodic intervals. in either case, only when the lock bit is set, is the pllclk clock safe to use as the source for the system and core clocks. if the pll is selected as the source for the system and core clocks and the lock bit is clear, the pll has suffered a severe noise hit and the software must take appropriate action, depending on the application. the following conditions apply when the pll is in automatic bandwidth control mode (auto = 1): the track bit is a read-only indicator of the mode of the ?ter. the track bit is set when the vco frequency is within a certain tolerance, ? trk , and is clear when the vco frequency is out of a certain tolerance, ? unt . the lock bit is a read-only indicator of the locked state of the pll. the lock bit is set when the vco frequency is within a certain tolerance, ? lock , and is cleared when the vco frequency is out of a certain tolerance, ? unl . cpu interrupts can occur if enabled (lockie = 1) when the lock condition changes, toggling the lock bit. the pll can also operate in manual mode (auto = 0). manual mode is used by systems that do not require an indicator of the lock condition for proper operation. such systems typically operate well below the maximum system frequency (f sys ) and require fast start-up. the following conditions apply when in manual mode: acq is a writable control bit that controls the mode of the ?ter. before turning on the pll in manual mode, the acq bit should be asserted to con?ure the ?ter in acquisition mode. after turning on the pll by setting the pllon bit software must wait a given time (t acq ) before entering tracking mode (acq = 0). after entering tracking mode software must wait a given time (t al ) before selecting the pllclk as the source for system and core clocks (pllsel = 1).
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 269 rev 1.09 9.4.2 system clocks generator figure 9-17. system clocks generator the clock generator creates the clocks used in the mcu (see figure 9-17 ). the gating condition placed on top of the individual clock gates indicates the dependencies of different modes (stop, wait) and the setting of the respective con?uration bits. the peripheral modules use the bus clock. some peripheral modules also use the oscillator clock. the memory blocks use the bus clock. if the mcu enters self-clock mode (see section 9.4.7.2, ?elf-clock mode ?, oscillator clock source is switched to pllclk running at its minimum frequency f scm . the bus clock is used to generate the clock visible at the eclk pin. the core clock signal is the clock for the cpu. the core clock is twice the bus clock as shown in figure 9-18 . but note that a cpu cycle corresponds to one bus clock. pll clock mode is selected with pllsel bit in the clksel register. when selected, the pll output clock drives sysclk for the main system including the cpu and peripherals. the pll cannot be turned off by clearing the pllon bit, if the pll clock is selected. when pllsel is changed, it takes a maximum oscillator phase lock loop extal xtal sysclk rti oscclk pllclk clock phase generator bus clock clock monitor 1 0 pllsel or scm 2 core clock cop oscillator oscillator = clock gate gating condition wait(cwai,syswai), stop wait(rtiwai), stop( pstp, pre), rti enable wait(copwai), stop( pstp, pce), cop enable wait(syswai), stop stop( pstp) 1 0 scm wait(syswai), stop clock clock (running during pseudo-stop mode
chapter 9 clocks and reset generator (crgv4) block description 270 mc9s12q128 freescale semiconductor rev 1.09 of 4 oscclk plus 4 pllclk cycles to make the transition. during the transition, all clocks freeze and cpu activity ceases. figure 9-18. core clock and bus clock relationship 9.4.3 clock monitor (cm) if no oscclk edges are detected within a certain time, the clock monitor within the oscillator block generates a clock monitor fail event. the crgv4 then asserts self-clock mode or generates a system reset depending on the state of scme bit. if the clock monitor is disabled or the presence of clocks is detected no failure is indicated by the oscillator block.the clock monitor function is enabled/disabled by the cme control bit. 9.4.4 clock quality checker the clock monitor performs a coarse check on the incoming clock signal. the clock quality checker provides a more accurate check in addition to the clock monitor. a clock quality check is triggered by any of the following events: power-on reset (por) low voltage reset (lvr) wake-up from full stop mode (exit full stop) clock monitor fail indication (cm fail) a time window of 50000 vco clock cycles 1 is called check window . a number greater equal than 4096 rising oscclk edges within a check window is called osc ok . note that osc ok immediately terminates the current check window . see figure 9-19 as an example. figure 9-19. check window example 1. vco clock cycles are generated by the pll when running at minimum frequency f scm . core clock: bus clock / eclk 12 49999 50000 vco clock check window 12345 4095 4096 3 oscclk osc ok
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 271 rev 1.09 the sequence for clock quality check is shown in figure 9-20 . figure 9-20. sequence for clock quality check note remember that in parallel to additional actions caused by self-clock mode or clock monitor reset 1 handling the clock quality checker continues to check the oscclk signal. note the clock quality checker enables the pll and the voltage regulator (vreg) anytime a clock check has to be performed. an ongoing clock quality check could also cause a running pll (f scm ) and an active vreg during pseudo-stop mode or wait mode 1. a clock monitor reset will always set the scme bit to logical? check window osc ok ? scm active? switch to oscclk exit scm clock ok num=0 num<50 ? num=num+1 yes no yes scme=1 ? no enter scm scm active? yes clock monitor reset no yes no num=50 yes no por exit full stop cm fail lv r
chapter 9 clocks and reset generator (crgv4) block description 272 mc9s12q128 freescale semiconductor rev 1.09 9.4.5 computer operating properly watchdog (cop) figure 9-21. clock chain for cop the cop (free running watchdog timer) enables the user to check that a program is running and sequencing properly. the cop is disabled out of reset. when the cop is being used, software is responsible for keeping the cop from timing out. if the cop times out it is an indication that the software is no longer being executed in the intended sequence; thus a system reset is initiated (see section 9.5.2, ?omputer operating properly watchdog (cop) reset ).?the cop runs with a gated oscclk (see section figure 9-21., ?lock chain for cop ?. three control bits in the copctl register allow selection of seven cop time-out periods. when cop is enabled, the program must write 0x0055 and 0x00aa (in this order) to the armcop register during the selected time-out period. as soon as this is done, the cop time-out period is restarted. if the program fails to do this and the cop times out, the part will reset. also, if any value other than 0x0055 or 0x00aa is written, the part is immediately reset. windowed cop operation is enabled by setting wcop in the copctl register. in this mode, writes to the armcop register to clear the cop timer must occur in the last 25% of the selected time-out period. a premature write will immediately reset the part. if pce bit is set, the cop will continue to run in pseudo-stop mode. 9.4.6 real-time interrupt (rti) the rti can be used to generate a hardware interrupt at a ?ed periodic rate. if enabled (by setting rtie=1), this interrupt will occur at the rate selected by the rtictl register. the rti runs with a gated oscclk (see section figure 9-22., ?lock chain for rti ?. at the end of the rti time-out period the rtif ?g is set to 1 and a new rti time-out period starts immediately. a write to the rtictl register restarts the rti time-out period. oscclk cr[2:0] cop timeout 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 4 4 2 4 2 16384 4 cr[2:0] = clock gate wait(copwai), stop( pstp, pce), cop enable gating condition
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 273 rev 1.09 if the pre bit is set, the rti will continue to run in pseudo-stop mode. . figure 9-22. clock chain for rti 9.4.7 modes of operation 9.4.7.1 normal mode the crgv4 block behaves as described within this speci?ation in all normal modes. 9.4.7.2 self-clock mode the vco has a minimum operating frequency, f scm . if the external clock frequency is not available due to a failure or due to long crystal start-up time, the bus clock and the core clock are derived from the vco running at minimum operating frequency; this mode of operation is called self-clock mode. this requires cme = 1 and scme = 1. if the mcu was clocked by the pll clock prior to entering self-clock mode, the pllsel bit will be cleared. if the external clock signal has stabilized again, the crg will automatically select oscclk to be the system clock and return to normal mode. see section 9.4.4, ?lock quality checker ?for more information on entering and leaving self-clock mode. oscclk rtr[6:4] 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 counter (rtr[3:0]) 4-bit modulus 1024 rti timeout = clock gate wait(rtiwai), stop( pstp, pre), rti enable gating condition
chapter 9 clocks and reset generator (crgv4) block description 274 mc9s12q128 freescale semiconductor rev 1.09 note in order to detect a potential clock loss, the cme bit should be always enabled (cme=1). if cme bit is disabled and the mcu is con?ured to run on pll clock (pllclk), a loss of external clock (oscclk) will not be detected and will cause the system clock to drift towards the vcos minimum frequency f scm . as soon as the external clock is available again the system clock ramps up to its pll target frequency. if the mcu is running on external clock any loss of clock will cause the system to go static. 9.4.8 low-power operation in run mode the rti can be stopped by setting the associated rate select bits to 0. the cop can be stopped by setting the associated rate select bits to 0. 9.4.9 low-power operation in wait mode the wai instruction puts the mcu in a low power consumption stand-by mode depending on setting of the individual bits in the clksel register. all individual wait mode con?uration bits can be superposed. this provides enhanced granularity in reducing the level of power consumption during wait mode. table 9- 10 lists the individual con?uration bits and the parts of the mcu that are affected in wait mode. after executing the wai instruction the core requests the crg to switch mcu into wait mode. the crg then checks whether the pllwai, cwai and syswai bits are asserted (see figure 9-23 ). depending on the con?uration the crg switches the system and core clocks to oscclk by clearing the pllsel bit, disables the pll, disables the core clocks and ?ally disables the remaining system clocks. as soon as all clocks are switched off wait mode is active. table 9-10. mcu con?uration during wait mode pllwai cwai syswai rtiwai copwai roawai pll stopped core stopped stopped system stopped rti stopped cop stopped oscillator reduced (1) 1. refer to oscillator block description for availability of a reduced oscillator amplitude.
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 275 rev 1.09 figure 9-23. wait mode entry/exit sequence enter wait mode pllwai=1 ? exit wait w. cmreset exit wait w. ext.reset exit wait mode enter scm exit wait mode core reqs wait mode. cwai or syswai=1 ? syswai=1 ? clear pllsel, disable pll disable core clocks disable system clocks cme=1 ? int ? cm fail ? scme=1 ? scmie=1 ? continue w. normal op no no no no no no no yes yes yes yes yes no yes yes yes wait mode left due to external reset generate scm interrupt (wakeup from wait) scm=1 ? enter scm no yes
chapter 9 clocks and reset generator (crgv4) block description 276 mc9s12q128 freescale semiconductor rev 1.09 there are ve different scenarios for the crg to restart the mcu from wait mode: external reset clock monitor reset cop reset self-clock mode interrupt real-time interrupt (rti) if the mcu gets an external reset during wait mode active, the crg asynchronously restores all con?uration bits in the register space to its default settings and starts the reset generator. after completing the reset sequence processing begins by fetching the normal reset vector. wait mode is exited and the mcu is in run mode again. if the clock monitor is enabled (cme=1) the mcu is able to leave wait mode when loss of oscillator/external clock is detected by a clock monitor fail. if the scme bit is not asserted the crg generates a clock monitor fail reset (cmreset). the crgs behavior for cmreset is the same compared to external reset, but another reset vector is fetched after completion of the reset sequence. if the scme bit is asserted the crg generates a scm interrupt if enabled (scmie=1). after generating the interrupt the crg enters self-clock mode and starts the clock quality checker (see section 9.4.4, ?lock quality checker ?. then the mcu continues with normal operation.if the scm interrupt is blocked by scmie = 0, the scmif ?g will be asserted and clock quality checks will be performed but the mcu will not wake-up from wait mode. if any other interrupt source (e.g. rti) triggers exit from wait mode the mcu immediately continues with normal operation. if the pll has been powered-down during wait mode the pllsel bit is cleared and the mcu runs on oscclk after leaving wait mode. the software must manually set the pllsel bit again, in order to switch system and core clocks to the pllclk. if wait mode is entered from self-clock mode, the crg will continue to check the clock quality until clock check is successful. the pll and voltage regulator (vreg) will remain enabled. table 9-11 summarizes the outcome of a clock loss while in wait mode.
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 277 rev 1.09 table 9-11. outcome of clock loss in wait mode cme scme scmie crg actions 0 x x clock failure --> no action, clock loss not detected. 1 0 x clock failure --> crg performs clock monitor reset immediately 1 1 0 clock failure --> scenario 1: oscclk recovers prior to exiting wait mode. ?mcu remains in wait mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g. some time later oscclk recovers. ?cm no longer indicates a failure, ?4096 oscclk cycles later clock quality check indicates clock o.k., ?scm deactivated, ?pll disabled depending on pllwai, ?vreg remains enabled (never gets disabled in wait mode) . ?mcu remains in wait mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit wait mode using oscclk as system clock (sysclk), ?continue normal operation. or an external reset is applied. ?exit wait mode using oscclk as system clock, ?start reset sequence. scenario 2: oscclk does not recover prior to exiting wait mode. ?mcu remains in wait mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g, ?keep performing clock quality checks (could continue in?itely) while in wait mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit wait mode in scm using pll clock (f scm ) as system clock, ?continue to perform additional clock quality checks until oscclk is o.k. again. or an external reset is applied. ?exit wait mode in scm using pll clock (f scm ) as system clock, ?start reset sequence, ?continue to perform additional clock quality checks until oscclk is o.k.again.
chapter 9 clocks and reset generator (crgv4) block description 278 mc9s12q128 freescale semiconductor rev 1.09 9.4.10 low-power operation in stop mode all clocks are stopped in stop mode, dependent of the setting of the pce, pre and pstp bit. the oscillator is disabled in stop mode unless the pstp bit is set. all counters and dividers remain frozen but do not initialize. if the pre or pce bits are set, the rti or cop continues to run in pseudo-stop mode. in addition to disabling system and core clocks the crg requests other functional units of the mcu (e.g. voltage-regulator) to enter their individual power-saving modes (if available). this is the main difference between pseudo-stop mode and wait mode. after executing the stop instruction the core requests the crg to switch the mcu into stop mode. if the pllsel bit remains set when entering stop mode, the crg will switch the system and core clocks to oscclk by clearing the pllsel bit. then the crg disables the pll, disables the core clock and ?ally disables the remaining system clocks. as soon as all clocks are switched off, stop mode is active. if pseudo-stop mode (pstp = 1) is entered from self-clock mode the crg will continue to check the clock quality until clock check is successful. the pll and the voltage regulator (vreg) will remain enabled. if full stop mode (pstp = 0) is entered from self-clock mode an ongoing clock quality check will be stopped. a complete timeout window check will be started when stop mode is exited again. wake-up from stop mode also depends on the setting of the pstp bit. 1 1 1 clock failure --> ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?scmif set. scmif generates self-clock mode wakeup interrupt. ?exit wait mode in scm using pll clock (f scm ) as system clock, ?continue to perform a additional clock quality checks until oscclk is o.k. again. table 9-11. outcome of clock loss in wait mode (continued) cme scme scmie crg actions
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 279 rev 1.09 figure 9-24. stop mode entry/exit sequence 9.4.10.1 wake-up from pseudo-stop (pstp=1) wake-up from pseudo-stop is the same as wake-up from wait mode. there are also three different scenarios for the crg to restart the mcu from pseudo-stop mode: external reset clock monitor fail wake-up interrupt exit stop w. cmreset exit stop mode enter scm exit stop mode core reqs stop mode. clear pllsel, disable pll cme=1 ? int ? cm fail ? scme=1 ? scmie=1 ? continue w. normal op no no no no yes yes yes yes yes generate scm interrupt (wakeup from stop) enter stop mode exit stop w. ext.reset wait mode left due to external clock ok ? scme=1 ? enter scm yes no yes exit stop w. cmreset no no no pstp=1 ? int ? yes no yes exit stop mode exit stop mode scm=1 ? enter scm no yes
chapter 9 clocks and reset generator (crgv4) block description 280 mc9s12q128 freescale semiconductor rev 1.09 if the mcu gets an external reset during pseudo-stop mode active, the crg asynchronously restores all con?uration bits in the register space to its default settings and starts the reset generator. after completing the reset sequence processing begins by fetching the normal reset vector. pseudo-stop mode is exited and the mcu is in run mode again. if the clock monitor is enabled (cme = 1) the mcu is able to leave pseudo-stop mode when loss of oscillator/external clock is detected by a clock monitor fail. if the scme bit is not asserted the crg generates a clock monitor fail reset (cmreset). the crgs behavior for cmreset is the same compared to external reset, but another reset vector is fetched after completion of the reset sequence. if the scme bit is asserted the crg generates a scm interrupt if enabled (scmie=1). after generating the interrupt the crg enters self-clock mode and starts the clock quality checker (see section 9.4.4, ?lock quality checker ?. then the mcu continues with normal operation. if the scm interrupt is blocked by scmie = 0, the scmif ?g will be asserted but the crg will not wake-up from pseudo-stop mode. if any other interrupt source (e.g. rti) triggers exit from pseudo-stop mode the mcu immediately continues with normal operation. because the pll has been powered-down during stop mode the pllsel bit is cleared and the mcu runs on oscclk after leaving stop mode. the software must set the pllsel bit again, in order to switch system and core clocks to the pllclk. table 9-12 summarizes the outcome of a clock loss while in pseudo-stop mode.
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 281 rev 1.09 table 9-12. outcome of clock loss in pseudo-stop mode cme scme scmie crg actions 0 x x clock failure --> no action, clock loss not detected. 1 0 x clock failure --> crg performs clock monitor reset immediately 1 1 0 clock monitor failure --> scenario 1: oscclk recovers prior to exiting pseudo-stop mode. ?mcu remains in pseudo-stop mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g. some time later oscclk recovers. ?cm no longer indicates a failure, ?4096 oscclk cycles later clock quality check indicates clock o.k., ?scm deactivated, ?pll disabled, ?vreg disabled. ?mcu remains in pseudo-stop mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit pseudo-stop mode using oscclk as system clock (sysclk), ?continue normal operation. or an external reset is applied. ?exit pseudo-stop mode using oscclk as system clock, ?start reset sequence. scenario 2: oscclk does not recover prior to exiting pseudo-stop mode. ?mcu remains in pseudo-stop mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g, ?keep performing clock quality checks (could continue in?itely) while in pseudo-stop mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit pseudo-stop mode in scm using pll clock (f scm ) as system clock ?continue to perform additional clock quality checks until oscclk is o.k. again. or an external reset is applied. ?exit pseudo-stop mode in scm using pll clock (f scm ) as system clock ?start reset sequence, ?continue to perform additional clock quality checks until oscclk is o.k.again.
chapter 9 clocks and reset generator (crgv4) block description 282 mc9s12q128 freescale semiconductor rev 1.09 9.4.10.2 wake-up from full stop (pstp=0) the mcu requires an external interrupt or an external reset in order to wake-up from stop mode. if the mcu gets an external reset during full stop mode active, the crg asynchronously restores all con?uration bits in the register space to its default settings and will perform a maximum of 50 clock check_windows (see section 9.4.4, ?lock quality checker ?. after completing the clock quality check the crg starts the reset generator. after completing the reset sequence processing begins by fetching the normal reset vector. full stop mode is exited and the mcu is in run mode again. if the mcu is woken-up by an interrupt, the crg will also perform a maximum of 50 clock check_window s (see section 9.4.4, ?lock quality checker ?. if the clock quality check is successful, the crg will release all system and core clocks and will continue with normal operation. if all clock checks within the timeout-window are failing, the crg will switch to self-clock mode or generate a clock monitor reset (cmreset) depending on the setting of the scme bit. because the pll has been powered-down during stop mode the pllsel bit is cleared and the mcu runs on oscclk after leaving stop mode. the software must manually set the pllsel bit again, in order to switch system and core clocks to the pllclk. note in full stop mode, the clock monitor is disabled and any loss of clock will not be detected. 9.5 resets this section describes how to reset the crgv4 and how the crgv4 itself controls the reset of the mcu. it explains all special reset requirements. because the reset generator for the mcu is part of the crg, this section also describes all automatic actions that occur during or as a result of individual reset conditions. the reset values of registers and signals are provided in section 9.3, ?emory map and register 1 1 1 clock failure --> ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?scmif set. scmif generates self-clock mode wakeup interrupt. ?exit pseudo-stop mode in scm using pll clock (f scm ) as system clock, ?continue to perform a additional clock quality checks until oscclk is o.k. again. table 9-12. outcome of clock loss in pseudo-stop mode (continued) cme scme scmie crg actions
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 283 rev 1.09 de?ition . all reset sources are listed in table 9-13 . refer to the device overview chapter for related vector addresses and priorities. the reset sequence is initiated by any of the following events: low level is detected at the reset pin (external reset). power on is detected. low voltage is detected. cop watchdog times out. clock monitor failure is detected and self-clock mode was disabled (scme = 0). upon detection of any reset event, an internal circuit drives the reset pin low for 128 sysclk cycles (see figure 9-25 ). because entry into reset is asynchronous it does not require a running sysclk. however, the internal reset circuit of the crgv4 cannot sequence out of current reset condition without a running sysclk. the number of 128 sysclk cycles might be increased by n = 3 to 6 additional sysclk cycles depending on the internal synchronization latency. after 128+n sysclk cycles the reset pin is released. the reset generator of the crgv4 waits for additional 64 sysclk cycles and then samples the reset pin to determine the originating source. table 9-14 shows which vector will be fetched. note external circuitry connected to the reset pin should not include a large capacitance that would interfere with the ability of this signal to rise to a valid logic 1 within 64 sysclk cycles after the low drive is released. table 9-13. reset summary reset source local enable power-on reset none low voltage reset none external reset none clock monitor reset pllctl (cme=1, scme=0) cop watchdog reset copctl (cr[2:0] nonzero) table 9-14. reset vector selection sampled reset pin (64 cycles after release) clock monitor reset pending cop reset pending vector fetch 1 0 0 por / lvr / external reset 1 1 x clock monitor reset 1 0 1 cop reset 0 x x por / lvr / external reset with rise of reset pin
chapter 9 clocks and reset generator (crgv4) block description 284 mc9s12q128 freescale semiconductor rev 1.09 the internal reset of the mcu remains asserted while the reset generator completes the 192 sysclk long reset sequence. the reset generator circuitry always makes sure the internal reset is deasserted synchronously after completion of the 192 sysclk cycles. in case the reset pin is externally driven low for more than these 192 sysclk cycles (external reset), the internal reset remains asserted too. figure 9-25. reset timing 9.5.1 clock monitor reset the crgv4 generates a clock monitor reset in case all of the following conditions are true: clock monitor is enabled (cme=1) loss of clock is detected self-clock mode is disabled (scme=0) the reset event asynchronously forces the con?uration registers to their default settings (see section 9.3, ?emory map and register de?ition ?. in detail the cme and the scme are reset to logical ? (which doesnt change the state of the cme bit, because it has already been set). as a consequence, the crg immediately enters self-clock mode and starts its internal reset sequence. in parallel the clock quality check starts. as soon as clock quality check indicates a valid oscillator clock the crg switches to oscclk and leaves self-clock mode. because the clock quality checker is running in parallel to the reset generator, the crg may leave self-clock mode while completing the internal reset sequence. when the reset sequence is ?ished the crg checks the internally latched state of the clock monitor fail circuit. if a clock monitor fail is indicated processing begins by fetching the clock monitor reset vector. 9.5.2 computer operating properly watchdog (cop) reset when cop is enabled, the crg expects sequential write of 0x0055 and 0x00aa (in this order) to the armcop register during the selected time-out period. as soon as this is done, the cop time-out period restarts. if the program fails to do this the crg will generate a reset. also, if any value other than 0x0055 or 0x00aa is written, the crg immediately generates a reset. in case windowed cop operation is enabled ) ( ) ( ) ( ) sysclk 128+ n cycles 64 cycles with n being min 3 / max 6 cycles depending on internal synchronization delay crg drives reset pin low possibly sysclk not running possibly reset driven low externally ) ( ( reset reset pin released
chapter 9 clocks and reset generator (crgv4) block description freescale semiconductor mc9s12q128 285 rev 1.09 writes (0x0055 or 0x00aa) to the armcop register must occur in the last 25% of the selected time-out period. a premature write the crg will immediately generate a reset. as soon as the reset sequence is completed the reset generator checks the reset condition. if no clock monitor failure is indicated and the latched state of the cop timeout is true, processing begins by fetching the cop vector. 9.5.3 power-on reset, low voltage reset the on-chip voltage regulator detects when v dd to the mcu has reached a certain level and asserts power- on reset or low voltage reset or both. as soon as a power-on reset or low voltage reset is triggered the crg performs a quality check on the incoming clock signal. as soon as clock quality check indicates a valid oscillator clock signal the reset sequence starts using the oscillator clock. if after 50 check windows the clock quality check indicated a non-valid oscillator clock the reset sequence starts using self-clock mode. figure 9-26 and figure 9-27 show the power-up sequence for cases when the reset pin is tied to v dd and when the reset pin is held low. figure 9-26. reset pin tied to v dd (by a pull-up resistor) figure 9-27. reset pin held low externally reset internal por 128 sysclk 64 sysclk internal reset clock quality check (no self-clock mode) ) ( ) ( ) ( clock quality check reset internal por internal reset 128 sysclk 64 sysclk (no self-clock mode) ) ( ) ( ) (
chapter 9 clocks and reset generator (crgv4) block description 286 mc9s12q128 freescale semiconductor rev 1.09 9.6 interrupts the interrupts/reset vectors requested by the crg are listed in table 9-15 . refer to the device overview chapter for related vector addresses and priorities. 9.6.1 real-time interrupt the crgv4 generates a real-time interrupt when the selected interrupt time period elapses. rti interrupts are locally disabled by setting the rtie bit to 0. the real-time interrupt ?g (rtif) is set to 1 when a timeout occurs, and is cleared to 0 by writing a 1 to the rtif bit. the rti continues to run during pseudo-stop mode if the pre bit is set to 1. this feature can be used for periodic wakeup from pseudo-stop if the rti interrupt is enabled. 9.6.2 pll lock interrupt the crgv4 generates a pll lock interrupt when the lock condition of the pll has changed, either from a locked state to an unlocked state or vice versa. lock interrupts are locally disabled by setting the lockie bit to 0. the pll lock interrupt ?g (lockif) is set to1 when the lock condition has changed, and is cleared to 0 by writing a 1 to the lockif bit. 9.6.3 self-clock mode interrupt the crgv4 generates a self-clock mode interrupt when the scm condition of the system has changed, either entered or exited self-clock mode. scm conditions can only change if the self-clock mode enable bit (scme) is set to 1. scm conditions are caused by a failing clock quality check after power-on reset (por) or low voltage reset (lvr) or recovery from full stop mode (pstp = 0) or clock monitor failure. for details on the clock quality check refer to section 9.4.4, ?lock quality checker . if the clock monitor is enabled (cme = 1) a loss of external clock will also cause a scm condition (scme = 1). scm interrupts are locally disabled by setting the scmie bit to 0. the scm interrupt ?g (scmif) is set to 1 when the scm condition has changed, and is cleared to 0 by writing a 1 to the scmif bit. table 9-15. crg interrupt vectors interrupt source ccr mask local enable real-time interrupt i bit crgint (rtie) lock interrupt i bit crgint (lockie) scm interrupt i bit crgint (scmie)
freescale semiconductor mc9s12q128 287 rev 1.09 chapter 10 freescales scalable controller area network (s12mscanv2) 10.1 introduction freescales scalable controller area network (s12mscanv2) de?ition is based on the mscan12 de?ition, which is the speci? implementation of the mscan concept targeted for the m68hc12 microcontroller family. the module is a communication controller implementing the can 2.0a/b protocol as de?ed in the bosch speci?ation dated september 1991. for users to fully understand the mscan speci?ation, it is recommended that the bosch speci?ation be read ?st to familiarize the reader with the terms and concepts contained within this document. though not exclusively intended for automotive applications, can protocol is designed to meet the speci? requirements of a vehicle serial data bus: real-time processing, reliable operation in the emi environment of a vehicle, cost-effectiveness, and required bandwidth. mscan uses an advanced buffer arrangement resulting in predictable real-time behavior and simpli?d application software. 10.1.1 glossary ack: acknowledge of can message can: controller area network crc: cyclic redundancy code eof: end of frame fifo: first-in-first-out memory ifs: inter-frame sequence sof: start of frame cpu bus: cpu related read/write data bus can bus: can protocol related serial bus oscillator clock: direct clock from external oscillator bus clock: cpu bus realated clock can clock: can protocol related clock
chapter 10 freescales scalable controller area network (s12mscanv2) 288 mc9s12q128 freescale semiconductor rev 1.09 10.1.2 block diagram figure 10-1. mscan block diagram 10.1.3 features the basic features of the mscan are as follows: implementation of the can protocol ?version 2.0a/b standard and extended data frames zero to eight bytes data length programmable bit rate up to 1 mbps 1 support for remote frames five receive buffers with fifo storage scheme three transmit buffers with internal prioritization using a ?ocal priority?concept flexible maskable identi?r ?ter supports two full-size (32-bit) extended identi?r ?ters, or four 16-bit ?ters, or eight 8-bit ?ters programmable wakeup functionality with integrated low-pass ?ter programmable loopback mode supports self-test operation programmable listen-only mode for monitoring of can bus separate signalling and interrupt capabilities for all can receiver and transmitter error states (warning, error passive, bus-off) programmable mscan clock source either bus clock or oscillator clock internal timer for time-stamping of received and transmitted messages three low-power modes: sleep, power down, and mscan enable global initialization of con?uration registers 1. depending on the actual bit timing and the clock jitter of the pll. rxcan txcan receive/ transmit engine message filtering and buffering control and status wake-up interrupt req. errors interrupt req. receive interrupt req. transmit interrupt req. canclk bus clock con?uration oscillator clock mux presc. tq clk mscan low pass filter wake-up registers
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 289 rev 1.09 10.1.4 modes of operation the following modes of operation are speci? to the mscan. see section 10.4, ?unctional description , for details. listen-only mode mscan sleep mode mscan initialization mode mscan power down mode 10.2 external signal description the mscan uses two external pins: 10.2.1 rxcan ?can receiver input pin rxcan is the mscan receiver input pin. 10.2.2 txcan ?can transmitter output pin txcan is the mscan transmitter output pin. the txcan output pin represents the logic level on the can bus: 0 = dominant state 1 = recessive state 10.2.3 can system a typical can system with mscan is shown in figure 10-2 . each can station is connected physically to the can bus lines through a transceiver device. the transceiver is capable of driving the large current needed for the can bus and has current protection against defective can or defective stations. figure 10-2. can system can bus can controller (mscan) transceiver can node 1 can node 2 can node n can_l can_h mcu txcan rxcan
chapter 10 freescales scalable controller area network (s12mscanv2) 290 mc9s12q128 freescale semiconductor rev 1.09 10.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the mscan. 10.3.1 module memory map figure 10-3 gives an overview on all registers and their individual bits in the mscan memory map. the register address results from the addition of base address and address offset . the base address is determined at the mcu level and can be found in the mcu memory map description. the address offset is de?ed at the module level. the mscan occupies 64 bytes in the memory space. the base address of the mscan module is determined at the mcu level when the mcu is de?ed. the register decode map is ?ed and begins at the ?st address of the module address offset. the detailed register descriptions follow in the order they appear in the register map.
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 291 rev 1.09 register name bit 7 6 5 4 3 2 1 bit 0 0x0000 canctl0 r rxfrm rxact cswai synch time wupe slprq initrq w 0x0001 canctl1 r cane clksrc loopb listen wupm slpak initak w 0x0002 canbtr0 r sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 w 0x0003 canbtr1 r samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 w 0x0004 canrflg r wupif cscif rstat1 rstat0 tstat1 tstat0 ovrif rxf w 0x0005 canrier r wupie cscie rstate1 rstate0 tstate1 tstate0 ovrie rxfie w 0x0006 cantflg r0 0 0 00 txe2 txe1 txe0 w 0x0007 cantier r00000 txeie2 txeie1 txeie0 w 0x0008 cantarq r00000 abtrq2 abtrq1 abtrq0 w 0x0009 cantaak r00000 abtak2 abtak1 abtak0 w 0x000a cantbsel r00000 tx2 tx1 tx0 w 0x000b canidac r0 0 idam1 idam0 0 idhit2 idhit1 idhit0 w 0x000c?x000d reserved r00000000 w 0x000e canrxerr r rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 w 0x000f cantxerr r txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 w = unimplemented or reserved u = unaffected figure 10-3. mscan register summary
chapter 10 freescales scalable controller area network (s12mscanv2) 292 mc9s12q128 freescale semiconductor rev 1.09 10.3.2 register descriptions this section describes in detail all the registers and register bits in the mscan module. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. all bits of all registers in this module are completely synchronous to internal clocks during a register read. 10.3.2.1 mscan control register 0 (canctl0) the canctl0 register provides various control bits of the mscan module as described below. 0x0010?x0013 canidar0? r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w 0x0014?x0017 canidmrx r am7 am6 am5 am4 am3 am2 am1 am0 w 0x0018?x001b canidar4? r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w 0x001c?x001f canidmr4? r am7 am6 am5 am4 am3 am2 am1 am0 w 0x0020?x002f canrxfg r see section 10.3.3, ?rogrammers model of message storage w 0x0030?x003f cantxfg r see section 10.3.3, ?rogrammers model of message storage w module base + 0x0000 76543210 r rxfrm rxact cswai synch time wupe slprq initrq w reset: 00000001 = unimplemented figure 10-4. mscan control register 0 (canctl0) register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved u = unaffected figure 10-3. mscan register summary (continued)
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 293 rev 1.09 note the canctl0 register, except wupe, initrq, and slprq, is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable again as soon as the initialization mode is exited (initrq = 0 and initak = 0). read: anytime write: anytime when out of initialization mode; exceptions are read-only rxact and synch, rxfrm (which is set by the module only), and initrq (which is also writable in initialization mode). table 10-1. canctl0 register field descriptions field description 7 rxfrm (1) received frame flag this bit is read and clear only. it is set when a receiver has received a valid message correctly, independently of the ?ter con?uration. after it is set, it remains set until cleared by software or reset. clearing is done by writing a 1. writing a 0 is ignored. this bit is not valid in loopback mode. 0 no valid message was received since last clearing this ?g 1 a valid message was received since last clearing of this ?g 6 rxact receiver active status ?this read-only ?g indicates the mscan is receiving a message. the ?g is controlled by the receiver front end. this bit is not valid in loopback mode. 0 mscan is transmitting or idle 2 1 mscan is receiving a message (including when arbitration is lost) (2) 5 cswai (3) can stops in wait mode enabling this bit allows for lower power consumption in wait mode by disabling all the clocks at the cpu bus interface to the mscan module. 0 the module is not affected during wait mode 1 the module ceases to be clocked during wait mode 4 synch synchronized status this read-only ?g indicates whether the mscan is synchronized to the can bus and able to participate in the communication process. it is set and cleared by the mscan. 0 mscan is not synchronized to the can bus 1 mscan is synchronized to the can bus 3 time timer enable this bit activates an internal 16-bit wide free running timer which is clocked by the bit clock rate. if the timer is enabled, a 16-bit time stamp will be assigned to each transmitted/received message within the active tx/rx buffer. right after the eof of a valid message on the can bus, the time stamp is written to the highest bytes (0x000e, 0x000f) in the appropriate buffer (see section 10.3.3, ?rogrammers model of message storage ?. the internal timer is reset (all bits set to 0) when disabled. this bit is held low in initialization mode. 0 disable internal mscan timer 1 enable internal mscan timer 2 wupe (4) wake-up enable this con?uration bit allows the mscan to restart from sleep mode when traf? on can is detected (see section 10.4.5.4, ?scan sleep mode ?. 0 wake-up disabled ?the mscan ignores traf? on can 1 wake-up enabled ?the mscan is able to restart
chapter 10 freescales scalable controller area network (s12mscanv2) 294 mc9s12q128 freescale semiconductor rev 1.09 10.3.2.2 mscan control register 1 (canctl1) the canctl1 register provides various control bits and handshake status information of the mscan module as described below. 1 slprq (5) sleep mode request ?this bit requests the mscan to enter sleep mode, which is an internal power saving mode (see section 10.4.5.4, ?scan sleep mode ?. the sleep mode request is serviced when the can bus is idle, i.e., the module is not receiving a message and all transmit buffers are empty. the module indicates entry to sleep mode by setting slpak = 1 (see section 10.3.2.2, ?scan control register 1 (canctl1) ?. slprq cannot be set while the wupif ?g is set (see section 10.3.2.5, ?scan receiver flag register (canrflg) ?. sleep mode will be active until slprq is cleared by the cpu or, depending on the setting of wupe, the mscan detects activity on the can bus and clears slprq itself. 0 running ?the mscan functions normally 1 sleep mode request ?the mscan enters sleep mode when can bus idle 0 initrq (6),(7) initialization mode request ?when this bit is set by the cpu, the mscan skips to initialization mode (see section 10.4.5.5, ?scan initialization mode ?. any ongoing transmission or reception is aborted and synchronization to the can bus is lost. the module indicates entry to initialization mode by setting initak = 1 ( section 10.3.2.2, ?scan control register 1 (canctl1) ?. the following registers enter their hard reset state and restore their default values: canctl0 (8) , canrflg (9) , canrier (10) , cantflg, cantier, cantarq, cantaak, and cantbsel. the registers canctl1, canbtr0, canbtr1, canidac, canidar0-7, and canidmr0-7 can only be written by the cpu when the mscan is in initialization mode (initrq = 1 and initak = 1). the values of the error counters are not affected by initialization mode. when this bit is cleared by the cpu, the mscan restarts and then tries to synchronize to the can bus. if the mscan is not in bus-off state, it synchronizes after 11 consecutive recessive bits on the can bus; if the mscan is in bus-off state, it continues to wait for 128 occurrences of 11 consecutive recessive bits. writing to other bits in canctl0, canrflg, canrier, cantflg, or cantier must be done only after initialization mode is exited, which is initrq = 0 and initak = 0. 0 normal operation 1 mscan in initialization mode 1. the mscan must be in normal mode for this bit to become set. 2. see the bosch can 2.0a/b speci?ation for a detailed de?ition of transmitter and receiver states. 3. in order to protect from accidentally violating the can protocol, the txcan pin is immediately forced to a recessive state when the cpu enters wait (cswai = 1) or stop mode (see section 10.4.5.2, ?peration in wait mode ?and section 10.4.5.3, ?peration in stop mode ? . 4. the cpu has to make sure that the wupe register and the wupie wake-up interrupt enable register (see section 10.3.2.6, ?scan receiver interrupt enable register (canrier) ) is enabled, if the recovery mechanism from stop or wait is required. 5. the cpu cannot clear slprq before the mscan has entered sleep mode (slprq = 1 and slpak = 1). 6. the cpu cannot clear initrq before the mscan has entered initialization mode (initrq = 1 and initak = 1). 7. in order to protect from accidentally violating the can protocol, the txcan pin is immediately forced to a recessive state when the initialization mode is requested by the cpu. thus, the recommended procedure is to bring the mscan into sleep mode (slprq = 1 and slpak = 1) before requesting initialization mode. 8. not including wupe, initrq, and slprq. 9. tstat1 and tstat0 are not affected by initialization mode. 10. rstat1 and rstat0 are not affected by initialization mode. table 10-1. canctl0 register field descriptions (continued) field description
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 295 rev 1.09 read: anytime write: anytime when initrq = 1 and initak = 1, except cane which is write once in normal and anytime in special system operation modes when the mscan is in initialization mode (initrq = 1 and initak = 1). module base + 0x0001 7 654 3 210 r cane clksrc loopb listen wupm slpak initak w reset: 0 0 0 1 0 0 0 1 = unimplemented figure 10-5. mscan control register 1 (canctl1) table 10-2. canctl1 register field descriptions field description 7 cane mscan enable 0 mscan module is disabled 1 mscan module is enabled 6 clksrc mscan clock source this bit de?es the clock source for the mscan module (only for systems with a clock generation module; section 10.4.3.2, ?lock system , and section figure 10-42., ?scan clocking scheme ,?. 0 mscan clock source is the oscillator clock 1 mscan clock source is the bus clock 5 loopb loopback self test mode when this bit is set, the mscan performs an internal loopback which can be used for self test operation. the bit stream output of the transmitter is fed back to the receiver internally. the rxcan input pin is ignored and the txcan output goes to the recessive state (logic 1). the mscan behaves as it does normally when transmitting and treats its own transmitted message as a message received from a remote node. in this state, the mscan ignores the bit sent during the ack slot in the can frame acknowledge ?ld to ensure proper reception of its own message. both transmit and receive interrupts are generated. 0 loopback self test disabled 1 loopback self test enabled 4 listen listen only mode this bit con?ures the mscan as a can bus monitor. when listen is set, all valid can messages with matching id are received, but no acknowledgement or error frames are sent out (see section 10.4.4.4, ?isten-only mode ?. in addition, the error counters are frozen. listen only mode supports applications which require ?ot plugging?or throughput analysis. the mscan is unable to transmit any messages when listen only mode is active. 0 normal operation 1 listen only mode activated 2 wupm wake-up mode ?if wupe in canctl0 is enabled, this bit de?es whether the integrated low-pass ?ter is applied to protect the mscan from spurious wake-up (see section 10.4.5.4, ?scan sleep mode ?. 0 mscan wakes up on any dominant level on the can bus 1 mscan wakes up only in case of a dominant pulse on the can bus that has a length of t wup
chapter 10 freescales scalable controller area network (s12mscanv2) 296 mc9s12q128 freescale semiconductor rev 1.09 1 slpak sleep mode acknowledge ?this ?g indicates whether the mscan module has entered sleep mode (see section 10.4.5.4, ?scan sleep mode ?. it is used as a handshake ?g for the slprq sleep mode request. sleep mode is active when slprq = 1 and slpak = 1. depending on the setting of wupe, the mscan will clear the ?g if it detects activity on the can bus while in sleep mode. 0 running ?the mscan operates normally 1 sleep mode active ?the mscan has entered sleep mode 0 initak initialization mode acknowledge ?this ?g indicates whether the mscan module is in initialization mode (see section 10.4.5.5, ?scan initialization mode ?. it is used as a handshake ?g for the initrq initialization mode request. initialization mode is active when initrq = 1 and initak = 1. the registers canctl1, canbtr0, canbtr1, canidac, canidar0?anidar7, and canidmr0?anidmr7 can be written only by the cpu when the mscan is in initialization mode. 0 running ?the mscan operates normally 1 initialization mode active ?the mscan has entered initialization mode table 10-2. canctl1 register field descriptions (continued) field description
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 297 rev 1.09 10.3.2.3 mscan bus timing register 0 (canbtr0) the canbtr0 register con?ures various can bus timing parameters of the mscan module. read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) module base + 0x0002 76543210 r sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 w reset: 00000000 figure 10-6. mscan bus timing register 0 (canbtr 0 ) table 10-3. canbtr 0 register field descriptions field description 7:6 sjw[1:0] synchronization jump width the synchronization jump width de?es the maximum number of time quanta (tq) clock cycles a bit can be shortened or lengthened to achieve resynchronization to data transitions on the can bus (see table 10-4 ). 5:0 brp[5:0] baud rate prescaler these bits determine the time quanta (tq) clock which is used to build up the bit timing (see table 10-5 ). table 10-4. synchronization jump width sjw1 sjw0 synchronization jump width 0 0 1 tq clock cycle 0 1 2 tq clock cycles 1 0 3 tq clock cycles 1 1 4 tq clock cycles table 10-5. baud rate prescaler brp5 brp4 brp3 brp2 brp1 brp0 prescaler value (p) 000000 1 000001 2 000010 3 000011 4 :::::: : 111111 64
chapter 10 freescales scalable controller area network (s12mscanv2) 298 mc9s12q128 freescale semiconductor rev 1.09 10.3.2.4 mscan bus timing register 1 (canbtr1) the canbtr1 register con?ures various can bus timing parameters of the mscan module. read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) module base + 0x0003 76543210 r samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 w reset: 00000000 figure 10-7. mscan bus timing register 1 (canbtr1) table 10-6. canbtr1 register field descriptions field description 7 samp sampling ?this bit determines the number of can bus samples taken per bit time. 0 one sample per bit. 1 three samples per bit (1) . if samp = 0, the resulting bit value is equal to the value of the single bit positioned at the sample point. if samp = 1, the resulting bit value is determined by using majority rule on the three total samples. for higher bit rates, it is recommended that only one sample is taken per bit time (samp = 0). 1. in this case, phase_seg1 must be at least 2 time quanta (tq). 6:4 tseg2[2:0] time segment 2 time segments within the bit time ? the number of clock cycles per bit time and the location of the sample point (see figure 10-43 ). time segment 2 (tseg2) values are programmable as shown in table 10-7 . 3:0 tseg1[3:0] time segment 1 time segments within the bit time ? the number of clock cycles per bit time and the location of the sample point (see figure 10-43 ). time segment 1 (tseg1) values are programmable as shown in table 10-8 . table 10-7. time segment 2 values tseg22 tseg21 tseg20 time segment 2 0 0 0 1 tq clock cycle (1) 1. this setting is not valid. please refer to table 10-34 for valid settings. 0 0 1 2 tq clock cycles ::: : 1 1 0 7 tq clock cycles 1 1 1 8 tq clock cycles
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 299 rev 1.09 the bit time is determined by the oscillator frequency, the baud rate prescaler, and the number of time quanta (tq) clock cycles per bit (as shown in table 10-7 and table 10-8 ). eqn. 10-1 10.3.2.5 mscan receiver flag register (canrflg) a ?g can be cleared only by software (writing a 1 to the corresponding bit position) when the condition which caused the setting is no longer valid. every ?g has an associated interrupt enable bit in the canrier register. note the canrflg register is held in the reset state 1 when the initialization mode is active (initrq = 1 and initak = 1). this register is writable again as soon as the initialization mode is exited (initrq = 0 and initak = 0). read: anytime write: anytime when out of initialization mode, except rstat[1:0] and tstat[1:0] ?gs which are read- only; write of 1 clears ?g; write of 0 is ignored. table 10-8. time segment 1 values tseg13 tseg12 tseg11 tseg10 time segment 1 0 0 0 0 1 tq clock cycle (1) 1. this setting is not valid. please refer to table 10-34 for valid settings. 0 0 0 1 2 tq clock cycles 1 0 0 1 0 3 tq clock cycles 1 0 0 1 1 4 tq clock cycles :::: : 1 1 1 0 15 tq clock cycles 1 1 1 1 16 tq clock cycles module base + 0x0004 76543210 r wupif cscif rstat1 rstat0 tstat1 tstat0 ovrif rxf w reset: 00000000 = unimplemented figure 10-8. mscan receiver flag register (canrflg) 1. the rstat[1:0], tstat[1:0] bits are not affected by initialization mode. bit time prescaler value () f canclk ----------------------------------------------------- - 1 timesegment1 timesegment2 ++ () ? =
chapter 10 freescales scalable controller area network (s12mscanv2) 300 mc9s12q128 freescale semiconductor rev 1.09 table 10-9. canrflg register field descriptions field description 7 wupif wake-up interrupt flag ?if the mscan detects can bus activity while in sleep mode (see section 10.4.5.4, ?scan sleep mode ,? and wupe = 1 in cantctl0 (see section 10.3.2.1, ?scan control register 0 (canctl0) ?, the module will set wupif. if not masked, a wake-up interrupt is pending while this ?g is set. 0 no wake-up activity observed while in sleep mode 1 mscan detected activity on the can bus and requested wake-up 6 cscif can status change interrupt flag ?this ?g is set when the mscan changes its current can bus status due to the actual value of the transmit error counter (tec) and the receive error counter (rec). an additional 4- bit (rstat[1:0], tstat[1:0]) status register, which is split into separate sections for tec/rec, informs the system on the actual can bus status (see section 10.3.2.6, ?scan receiver interrupt enable register (canrier) ?. if not masked, an error interrupt is pending while this ?g is set. cscif provides a blocking interrupt. that guarantees that the receiver/transmitter status bits (rstat/tstat) are only updated when no can status change interrupt is pending. if the tecs/recs change their current value after the cscif is asserted, which would cause an additional state change in the rstat/tstat bits, these bits keep their status until the current cscif interrupt is cleared again. 0 no change in can bus status occurred since last interrupt 1 mscan changed current can bus status 5:4 rstat[1:0] receiver status bits ?the values of the error counters control the actual can bus status of the mscan. as soon as the status change interrupt ?g (cscif) is set, these bits indicate the appropriate receiver related can bus status of the mscan. the coding for the bits rstat1, rstat0 is: 00 rxok: 0 receive error counter 96 01 rxwrn: 96 < receive error counter 127 10 rxerr: 127 < receive error counter 11 bus-off (1) : transmit error counter > 255 1. redundant information for the most critical can bus status which is ?us-off? this only occurs if the tx error counter exceeds a number of 255 errors. bus-off affects the receiver state. as soon as the transmitter leaves its bus-off state the receiver state skips to rxok too. refer also to tstat[1:0] coding in this register. 3:2 tstat[1:0] transmitter status bits ?the values of the error counters control the actual can bus status of the mscan. as soon as the status change interrupt ?g (cscif) is set, these bits indicate the appropriate transmitter related can bus status of the mscan. the coding for the bits tstat1, tstat0 is: 00 txok: 0 transmit error counter 96 01 txwrn: 96 < transmit error counter 127 10 txerr: 127 < transmit error counter 255 11 bus-off: transmit error counter > 255 1 ovrif overrun interrupt flag this ?g is set when a data overrun condition occurs. if not masked, an error interrupt is pending while this ?g is set. 0 no data overrun condition 1 a data overrun detected 0 rxf (2) 2. to ensure data integrity, do not read the receive buffer registers while the rxf ?g is cleared. for mcus with dual cpus, reading the receive buffer registers while the rxf ?g is cleared may result in a cpu fault condition. receive buffer full flag rxf is set by the mscan when a new message is shifted in the receiver fifo. this ?g indicates whether the shifted buffer is loaded with a correctly received message (matching identi?r, matching cyclic redundancy code (crc) and no other errors detected). after the cpu has read that message from the rxfg buffer in the receiver fifo, the rxf ?g must be cleared to release the buffer. a set rxf ?g prohibits the shifting of the next fifo entry into the foreground buffer (rxfg). if not masked, a receive interrupt is pending while this ?g is set. 0 no new message available within the rxfg 1 the receiver fifo is not empty. a new message is available in the rxfg
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 301 rev 1.09 10.3.2.6 mscan receiver interrupt enable register (canrier) this register contains the interrupt enable bits for the interrupt ?gs described in the canrflg register. note the canrier register is held in the reset state when the initialization mode is active (initrq=1 and initak=1). this register is writable when not in initialization mode (initrq=0 and initak=0). the rstate[1:0], tstate[1:0] bits are not affected by initialization mode. read: anytime write: anytime when not in initialization mode module base + 0x0005 76543210 r wupie cscie rstate1 rstate0 tstate1 tstate0 ovrie rxfie w reset: 00000000 figure 10-9. mscan receiver interrupt enable register (canrier) table 10-10. canrier register field descriptions field description 7 wupie (1) wake-up interrupt enable 0 no interrupt request is generated from this event. 1 a wake-up event causes a wake-up interrupt request. 6 cscie can status change interrupt enable 0 no interrupt request is generated from this event. 1 a can status change event causes an error interrupt request. 5:4 rstate[1:0] receiver status change enable these rstat enable bits control the sensitivity level in which receiver state changes are causing cscif interrupts. independent of the chosen sensitivity level the rstat ?gs continue to indicate the actual receiver state and are only updated if no cscif interrupt is pending. 00 do not generate any cscif interrupt caused by receiver state changes. 01 generate cscif interrupt only if the receiver enters or leaves ?us-off?state. discard other receiver state changes for generating cscif interrupt. 10 generate cscif interrupt only if the receiver enters or leaves ?xerr?or ?us-off (2) state. discard other receiver state changes for generating cscif interrupt. 11 generate cscif interrupt on all state changes. 3:2 tstate[1:0] transmitter status change enable these tstat enable bits control the sensitivity level in which transmitter state changes are causing cscif interrupts. independent of the chosen sensitivity level, the tstat ?gs continue to indicate the actual transmitter state and are only updated if no cscif interrupt is pending. 00 do not generate any cscif interrupt caused by transmitter state changes. 01 generate cscif interrupt only if the transmitter enters or leaves ?us-off?state. discard other transmitter state changes for generating cscif interrupt. 10 generate cscif interrupt only if the transmitter enters or leaves ?xerr?or ?us-off?state. discard other transmitter state changes for generating cscif interrupt. 11 generate cscif interrupt on all state changes.
chapter 10 freescales scalable controller area network (s12mscanv2) 302 mc9s12q128 freescale semiconductor rev 1.09 10.3.2.7 mscan transmitter flag register (cantflg) the transmit buffer empty ?gs each have an associated interrupt enable bit in the cantier register. note the cantflg register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). read: anytime write: anytime for txex ?gs when not in initialization mode; write of 1 clears ?g, write of 0 is ignored 1 ovrie overrun interrupt enable 0 no interrupt request is generated from this event. 1 an overrun event causes an error interrupt request. 0 rxfie receiver full interrupt enable 0 no interrupt request is generated from this event. 1 a receive buffer full (successful message reception) event causes a receiver interrupt request. 1. wupie and wupe (see section 10.3.2.1, ?scan control register 0 (canctl0) ? must both be enabled if the recovery mechanism from stop or wait is required. 2. bus-off state is de?ed by the can standard (see bosch can 2.0a/b protocol speci?ation: for only transmitters. because the only possible state change for the transmitter from bus-off to txok also forces the receiver to skip its current state to rxok, the coding of the rxstat[1:0] ?gs de?e an additional bus-off state for the receiver (see section 10.3.2.5, ?scan receiver flag register (canrflg) ?. module base + 0x0006 76543210 r0 0 0 00 txe2 txe1 txe0 w reset: 00000111 = unimplemented figure 10-10. mscan transmitter flag register (cantflg) table 10-10. canrier register field descriptions (continued) field description
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 303 rev 1.09 10.3.2.8 mscan transmitter interrupt enable register (cantier) this register contains the interrupt enable bits for the transmit buffer empty interrupt ?gs. note the cantier register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). read: anytime write: anytime when not in initialization mode table 10-11. cantflg register field descriptions field description 2:0 txe[2:0] transmitter buffer empty this ?g indicates that the associated transmit message buffer is empty, and thus not scheduled for transmission. the cpu must clear the ?g after a message is set up in the transmit buffer and is due for transmission. the mscan sets the ?g after the message is sent successfully. the ?g is also set by the mscan when the transmission request is successfully aborted due to a pending abort request (see section 10.3.2.9, ?scan transmitter message abort request register (cantarq) ?. if not masked, a transmit interrupt is pending while this ?g is set. clearing a txex ?g also clears the corresponding abtakx (see section 10.3.2.10, ?scan transmitter message abort acknowledge register (cantaak) ?. when a txex ?g is set, the corresponding abtrqx bit is cleared (see section 10.3.2.9, ?scan transmitter message abort request register (cantarq) ?. when listen-mode is active (see section 10.3.2.2, ?scan control register 1 (canctl1) ? the txex ?gs cannot be cleared and no transmission is started. read and write accesses to the transmit buffer will be blocked, if the corresponding txex bit is cleared (txex = 0) and the buffer is scheduled for transmission. 0 the associated message buffer is full (loaded with a message due for transmission) 1 the associated message buffer is empty (not scheduled) module base + 0x0007 76543210 r00000 txeie2 txeie1 txeie0 w reset: 00000000 = unimplemented figure 10-11. mscan transmitter interrupt enable register (cantier) table 10-12. cantier register field descriptions field description 2:0 txeie[2:0] transmitter empty interrupt enable 0 no interrupt request is generated from this event. 1 a transmitter empty (transmit buffer available for transmission) event causes a transmitter empty interrupt request.
chapter 10 freescales scalable controller area network (s12mscanv2) 304 mc9s12q128 freescale semiconductor rev 1.09 10.3.2.9 mscan transmitter message abort request register (cantarq) the cantarq register allows abort request of queued messages as described below. note the cantarq register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). read: anytime write: anytime when not in initialization mode module base + 0x0008 76543210 r00000 abtrq2 abtrq1 abtrq0 w reset: 00000000 = unimplemented figure 10-12. mscan transmitter message abort request register (cantarq) table 10-13. cantarq register field descriptions field description 2:0 abtrq[2:0] abort request ?the cpu sets the abtrqx bit to request that a scheduled message buffer (txex = 0) be aborted. the mscan grants the request if the message has not already started transmission, or if the transmission is not successful (lost arbitration or error). when a message is aborted, the associated txe (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ? and abort acknowledge ?gs (abtak, see section 10.3.2.10, ?scan transmitter message abort acknowledge register (cantaak) ? are set and a transmit interrupt occurs if enabled. the cpu cannot reset abtrqx. abtrqx is reset whenever the associated txe ?g is set. 0 no abort request 1 abort request pending
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 305 rev 1.09 10.3.2.10 mscan transmitter message abort acknowledge register (cantaak) the cantaak register indicates the successful abort of a queued message, if requested by the appropriate bits in the cantarq register. note the cantaak register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). read: anytime write: unimplemented for abtakx ?gs module base + 0x0009 76543210 r00000 abtak2 abtak1 abtak0 w reset: 00000000 = unimplemented figure 10-13. mscan transmitter message abort acknowledge register (cantaak) table 10-14. cantaak register field descriptions field description 2:0 abtak[2:0] abort acknowledge ?this ?g acknowledges that a message was aborted due to a pending abort request from the cpu. after a particular message buffer is ?gged empty, this ?g can be used by the application software to identify whether the message was aborted successfully or was sent anyway. the abtakx ?g is cleared whenever the corresponding txe ?g is cleared. 0 the message was not aborted. 1 the message was aborted.
chapter 10 freescales scalable controller area network (s12mscanv2) 306 mc9s12q128 freescale semiconductor rev 1.09 10.3.2.11 mscan transmit buffer selection register (cantbsel) the cantbsel register allows the selection of the actual transmit message buffer, which then will be accessible in the cantxfg register space. note the cantbsel register is held in the reset state when the initialization mode is active (initrq = 1 and initak=1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). read: find the lowest ordered bit set to 1, all other bits will be read as 0 write: anytime when not in initialization mode the following gives a short programming example of the usage of the cantbsel register: to get the next available transmit buffer, application software must read the cantflg register and write this value back into the cantbsel register. in this example tx buffers tx1 and tx2 are available. the value read from cantflg is therefore 0b0000_0110. when writing this value back to cantbsel, the tx buffer tx1 is selected in the cantxfg because the lowest numbered bit set to 1 is at bit position 1. reading back this value out of cantbsel results in 0b0000_0010, because only the lowest numbered bit position set to 1 is presented. this mechanism eases the application software the selection of the next available tx buffer. ldd cantflg; value read is 0b0000_0110 std cantbsel; value written is 0b0000_0110 ldd cantbsel; value read is 0b0000_0010 if all transmit message buffers are deselected, no accesses are allowed to the cantxfg registers. module base + 0x000a 76543210 r00000 tx2 tx1 tx0 w reset: 00000000 = unimplemented figure 10-14. mscan transmit buffer selection register (cantbsel) table 10-15. cantbsel register field descriptions field description 2:0 tx[2:0] transmit buffer select ?the lowest numbered bit places the respective transmit buffer in the cantxfg register space (e.g., tx1 = 1 and tx0 = 1 selects transmit buffer tx0; tx1 = 1 and tx0 = 0 selects transmit buffer tx1). read and write accesses to the selected transmit buffer will be blocked, if the corresponding txex bit is cleared and the buffer is scheduled for transmission (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ?. 0 the associated message buffer is deselected 1 the associated message buffer is selected, if lowest numbered bit
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 307 rev 1.09 10.3.2.12 mscan identi?r acceptance control register (canidac) the canidac register is used for identi?r acceptance control as described below. read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1), except bits idhitx, which are read- only module base + 0x000b 76543210 r0 0 idam1 idam0 0 idhit2 idhit1 idhit0 w reset: 00000000 = unimplemented figure 10-15. mscan identi?r acceptance control register (canidac) table 10-16. canidac register field descriptions field description 5:4 idam[1:0] identi?r acceptance mode the cpu sets these ?gs to de?e the identi?r acceptance ?ter organization (see section 10.4.3, ?denti?r acceptance filter ?. table 10-17 summarizes the different settings. in ?ter closed mode, no message is accepted such that the foreground buffer is never reloaded. 2:0 idhit[2:0] identi?r acceptance hit indicator ?the mscan sets these ?gs to indicate an identi?r acceptance hit (see section 10.4.3, ?denti?r acceptance filter ?. table 10-18 summarizes the different settings. table 10-17. identi?r acceptance mode settings idam1 idam0 identi?r acceptance mode 0 0 two 32-bit acceptance ?ters 0 1 four 16-bit acceptance ?ters 1 0 eight 8-bit acceptance ?ters 1 1 filter closed table 10-18. identi?r acceptance hit indication idhit2 idhit1 idhit0 identi?r acceptance hit 0 0 0 filter 0 hit 0 0 1 filter 1 hit 0 1 0 filter 2 hit 0 1 1 filter 3 hit 1 0 0 filter 4 hit 1 0 1 filter 5 hit 1 1 0 filter 6 hit 1 1 1 filter 7 hit
chapter 10 freescales scalable controller area network (s12mscanv2) 308 mc9s12q128 freescale semiconductor rev 1.09 the idhitx indicators are always related to the message in the foreground buffer (rxfg). when a message gets shifted into the foreground buffer of the receiver fifo the indicators are updated as well. 10.3.2.13 mscan reserved registers these registers are reserved for factory testing of the mscan module and is not available in normal system operation modes. read: always read 0x0000 in normal system operation modes write: unimplemented in normal system operation modes note writing to this register when in special modes can alter the mscan functionality. 10.3.2.14 mscan receive error counter (canrxerr) this register re?cts the status of the mscan receive error counter. read: only when in sleep mode (slprq = 1 and slpak = 1) or initialization mode (initrq = 1 and initak = 1) write: unimplemented module base + 0x000c, 0x000d 76543210 r00000000 w reset: 00000000 = unimplemented figure 10-16. mscan reserved registers module base + 0x000e 76543210 r rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 w reset: 00000000 = unimplemented figure 10-17. mscan receive error counter (canrxerr)
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 309 rev 1.09 note reading this register when in any other mode other than sleep or initialization mode may return an incorrect value. for mcus with dual cpus, this may result in a cpu fault condition. writing to this register when in special modes can alter the mscan functionality. 10.3.2.15 mscan transmit error counter (cantxerr) this register re?cts the status of the mscan transmit error counter. read: only when in sleep mode (slprq = 1 and slpak = 1) or initialization mode (initrq = 1 and initak = 1) write: unimplemented note reading this register when in any other mode other than sleep or initialization mode, may return an incorrect value. for mcus with dual cpus, this may result in a cpu fault condition. writing to this register when in special modes can alter the mscan functionality. module base + 0x000f 76543210 r txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 w reset: 00000000 = unimplemented figure 10-18. mscan transmit error counter (cantxerr)
chapter 10 freescales scalable controller area network (s12mscanv2) 310 mc9s12q128 freescale semiconductor rev 1.09 10.3.2.16 mscan identi?r acceptance registers (canidar0-7) on reception, each message is written into the background receive buffer. the cpu is only signalled to read the message if it passes the criteria in the identi?r acceptance and identi?r mask registers (accepted); otherwise, the message is overwritten by the next message (dropped). the acceptance registers of the mscan are applied on the idr0?dr3 registers (see section 10.3.3.1, ?denti?r registers (idr0?dr3) ? of incoming messages in a bit by bit manner (see section 10.4.3, ?denti?r acceptance filter ?. for extended identi?rs, all four acceptance and mask registers are applied. for standard identi?rs, only the ?st two (canidar0/1, canidmr0/1) are applied. read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) module base + 0x0010 (canidar0) 0x0011 (canidar1) 0x0012 (canidar2) 0x0013 (canidar3) 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 figure 10-19. mscan identi?r acceptance registers (first bank) ?canidar0?anidar3 table 10-19. canidar0?anidar3 register field descriptions field description 7:0 ac[7:0] acceptance code bits ac[7:0] comprise a user-de?ed sequence of bits with which the corresponding bits of the related identi?r register (idrn) of the receive message buffer are compared. the result of this comparison is then masked with the corresponding identi?r mask register.
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 311 rev 1.09 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) module base + 0x0018 (canidar4) 0x0019 (canidar5) 0x001a (canidar6) 0x001b (canidar7) 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 figure 10-20. mscan identi?r acceptance registers (second bank) ?canidar4?anidar7 table 10-20. canidar4?anidar7 register field descriptions field description 7:0 ac[7:0] acceptance code bits ac[7:0] comprise a user-de?ed sequence of bits with which the corresponding bits of the related identi?r register (idrn) of the receive message buffer are compared. the result of this comparison is then masked with the corresponding identi?r mask register.
chapter 10 freescales scalable controller area network (s12mscanv2) 312 mc9s12q128 freescale semiconductor rev 1.09 10.3.2.17 mscan identi?r mask registers (canidmr0?anidmr7) the identi?r mask register speci?s which of the corresponding bits in the identi?r acceptance register are relevant for acceptance ?tering. to receive standard identi?rs in 32 bit ?ter mode, it is required to program the last three bits (am[2:0]) in the mask registers canidmr1 and canidmr5 to ?ont care. to receive standard identi?rs in 16 bit ?ter mode, it is required to program the last three bits (am[2:0]) in the mask registers canidmr1, canidmr3, canidmr5, and canidmr7 to ?ont care. read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) module base + 0x0014 (canidmr0) 0x0015 (canidmr1) 0x0016 (canidmr2) 0x0017 (canidmr3) 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 figure 10-21. mscan identi?r mask registers (first bank) ?canidmr0?anidmr3 table 10-21. canidmr0?anidmr3 register field descriptions field description 7:0 am[7:0] acceptance mask bits if a particular bit in this register is cleared, this indicates that the corresponding bit in the identi?r acceptance register must be the same as its identi?r bit before a match is detected. the message is accepted if all such bits match. if a bit is set, it indicates that the state of the corresponding bit in the identi?r acceptance register does not affect whether or not the message is accepted. 0 match corresponding acceptance code register and identi?r bits 1 ignore corresponding acceptance code register bit
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 313 rev 1.09 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) module base + 0x001c (canidmr4) 0x001d (canidmr5) 0x001e (canidmr6) 0x001f (canidmr7) 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 figure 10-22. mscan identi?r mask registers (second bank) ?canidmr4?anidmr7 table 10-22. canidmr4?anidmr7 register field descriptions field description 7:0 am[7:0] acceptance mask bits if a particular bit in this register is cleared, this indicates that the corresponding bit in the identi?r acceptance register must be the same as its identi?r bit before a match is detected. the message is accepted if all such bits match. if a bit is set, it indicates that the state of the corresponding bit in the identi?r acceptance register does not affect whether or not the message is accepted. 0 match corresponding acceptance code register and identi?r bits 1 ignore corresponding acceptance code register bit
chapter 10 freescales scalable controller area network (s12mscanv2) 314 mc9s12q128 freescale semiconductor rev 1.09 10.3.3 programmers model of message storage the following section details the organization of the receive and transmit message buffers and the associated control registers. to simplify the programmer interface, the receive and transmit message buffers have the same outline. each message buffer allocates 16 bytes in the memory map containing a 13 byte data structure. an additional transmit buffer priority register (tbpr) is de?ed for the transmit buffers. within the last two bytes of this memory map, the mscan stores a special 16-bit time stamp, which is sampled from an internal timer after successful transmission or reception of a message. this feature is only available for transmit and receiver buffers, if the time bit is set (see section 10.3.2.1, ?scan control register 0 (canctl0) ?. the time stamp register is written by the mscan. the cpu can only read these registers. figure 10-23 shows the common 13-byte data structure of receive and transmit buffers for extended identi?rs. the mapping of standard identi?rs into the idr registers is shown in figure 10-24 . all bits of the receive and transmit buffers are ??out of reset because of ram-based implementation 1 . all reserved or unused bits of the receive and transmit buffers always read ?? table 10-23. message buffer organization offset address register access 0x00x0 identi?r register 0 0x00x1 identi?r register 1 0x00x2 identi?r register 2 0x00x3 identi?r register 3 0x00x4 data segment register 0 0x00x5 data segment register 1 0x00x6 data segment register 2 0x00x7 data segment register 3 0x00x8 data segment register 4 0x00x9 data segment register 5 0x00xa data segment register 6 0x00xb data segment register 7 0x00xc data length register 0x00xd transmit buffer priority register (1) 1. not applicable for receive buffers 0x00xe time stamp register (high byte) (2) 2. read-only for cpu 0x00xf time stamp register (low byte) (3) 3. read-only for cpu 1. exception: the transmit priority registers are 0 out of reset.
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 315 rev 1.09 read: for transmit buffers, anytime when txex ?g is set (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 10.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. for receive buffers, only when rxf ?g is set (see section 10.3.2.5, ?scan receiver flag register (canrflg) ?. register name bit 7 654321 bit0 0x00x0 idr0 r id28 id27 id26 id25 id24 id23 id22 id21 w 0x00x1 idr1 r id20 id19 id18 srr (=1) ide (=1) id17 id16 id15 w 0x00x2 idr2 r id14 id13 id12 id11 id10 id9 id8 id7 w 0x00x3 idr3 r id6 id5 id4 id3 id2 id1 id0 rtr w 0x00x4 dsr0 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x5 dsr1 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x6 dsr2 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x7 dsr3 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x8 dsr4 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x9 dsr5 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00xa dsr6 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00xb dsr7 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00xc dlr r dlc3 dlc2 dlc1 dlc0 w = unused, always read ? figure 10-23. receive/transmit message buffer ?extended identi?r mapping
chapter 10 freescales scalable controller area network (s12mscanv2) 316 mc9s12q128 freescale semiconductor rev 1.09 write: for transmit buffers, anytime when txex ?g is set (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 10.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. unimplemented for receive buffers. reset: unde?ed (0x00xx) because of ram-based implementation 10.3.3.1 identi?r registers (idr0?dr3) the identi?r registers for an extended format identi?r consist of a total of 32 bits; id[28:0], srr, ide, and rtr bits. the identi?r registers for a standard format identi?r consist of a total of 13 bits; id[10:0], rtr, and ide bits. 10.3.3.1.1 idr0?dr3 for extended identi?r mapping register name bit 7 654321 bit 0 idr0 0x00x0 r id10 id9 id8 id7 id6 id5 id4 id3 w idr1 0x00x1 r id2 id1 id0 rtr ide (=0) w idr2 0x00x2 r w idr3 0x00x3 r w = unused, always read ? figure 10-24. receive/transmit message buffer ?standard identi?r mapping module base + 0x00x1 76543210 r id28 id27 id26 id25 id24 id23 id22 id21 w reset: xxxxxxxx figure 10-25. identi?r register 0 (idr0) ?extended identi?r mapping table 10-24. idr0 register field descriptions ?extended field description 7:0 id[28:21] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number.
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 317 rev 1.09 module base + 0x00x1 76543210 r id20 id19 id18 srr (=1) ide (=1) id17 id16 id15 w reset: xxxxxxxx figure 10-26. identi?r register 1 (idr1) ?extended identi?r mapping table 10-25. idr1 register field descriptions ?extended field description 7:5 id[20:18] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. 4 srr substitute remote request ?this ?ed recessive bit is used only in extended format. it must be set to 1 by the user for transmission buffers and is stored as received on the can bus for receive buffers. 3 ide id extended this ?g indicates whether the extended or standard identi?r format is applied in this buffer. in the case of a receive buffer, the ?g is set as received and indicates to the cpu how to process the buffer identi?r registers. in the case of a transmit buffer, the ?g indicates to the mscan what type of identi?r to send. 0 standard format (11 bit) 1 extended format (29 bit) 2:0 id[17:15] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. module base + 0x00x2 76543210 r id14 id13 id12 id11 id10 id9 id8 id7 w reset: xxxxxxxx figure 10-27. identi?r register 2 (idr2) ?extended identi?r mapping table 10-26. idr2 register field descriptions ?extended field description 7:0 id[14:7] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number.
chapter 10 freescales scalable controller area network (s12mscanv2) 318 mc9s12q128 freescale semiconductor rev 1.09 10.3.3.1.2 idr0?dr3 for standard identi?r mapping module base + 0x00x3 76543210 r id6 id5 id4 id3 id2 id1 id0 rtr w reset: xxxxxxxx figure 10-28. identi?r register 3 (idr3) ?extended identi?r mapping table 10-27. idr3 register field descriptions ?extended field description 7:1 id[6:0] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. 0 rtr remote transmission request ?this ?g re?cts the status of the remote transmission request bit in the can frame. in the case of a receive buffer, it indicates the status of the received frame and supports the transmission of an answering frame in software. in the case of a transmit buffer, this ?g de?es the setting of the rtr bit to be sent. 0 data frame 1 remote frame module base + 0x00x0 76543210 r id10 id9 id8 id7 id6 id5 id4 id3 w reset: xxxxxxxx figure 10-29. identi?r register 0 ?standard mapping table 10-28. idr0 register field descriptions ?standard field description 7:0 id[10:3] standard format identi?r the identi?rs consist of 11 bits (id[10:0]) for the standard format. id10 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. see also id bits in table 10-29 .
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 319 rev 1.09 module base + 0x00x1 76543210 r id2 id1 id0 rtr ide (=0) w reset: xxxxxxxx = unused; always read ? figure 10-30. identi?r register 1 ?standard mapping table 10-29. idr1 register field descriptions field description 7:5 id[2:0] standard format identi?r the identi?rs consist of 11 bits (id[10:0]) for the standard format. id10 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. see also id bits in table 10-28 . 4 rtr remote transmission request this ?g re?cts the status of the remote transmission request bit in the can frame. in the case of a receive buffer, it indicates the status of the received frame and supports the transmission of an answering frame in software. in the case of a transmit buffer, this ?g de?es the setting of the rtr bit to be sent. 0 data frame 1 remote frame 3 ide id extended this ?g indicates whether the extended or standard identi?r format is applied in this buffer. in the case of a receive buffer, the ?g is set as received and indicates to the cpu how to process the buffer identi?r registers. in the case of a transmit buffer, the ?g indicates to the mscan what type of identi?r to send. 0 standard format (11 bit) 1 extended format (29 bit) module base + 0x00x2 76543210 r w reset: xxxxxxxx = unused; always read ? figure 10-31. identi?r register 2 ?standard mapping
chapter 10 freescales scalable controller area network (s12mscanv2) 320 mc9s12q128 freescale semiconductor rev 1.09 10.3.3.2 data segment registers (dsr0-7) the eight data segment registers, each with bits db[7:0], contain the data to be transmitted or received. the number of bytes to be transmitted or received is determined by the data length code in the corresponding dlr register. module base + 0x00x3 76543210 r w reset: xxxxxxxx = unused; always read ? figure 10-32. identi?r register 3 ?standard mapping module base + 0x0004 (dsr0) 0x0005 (dsr1) 0x0006 (dsr2) 0x0007 (dsr3) 0x0008 (dsr4) 0x0009 (dsr5) 0x000a (dsr6) 0x000b (dsr7) 76543210 r db7 db6 db5 db4 db3 db2 db1 db0 w reset: xxxxxxxx figure 10-33. data segment registers (dsr0?sr7) ?extended identi?r mapping table 10-30. dsr0?sr7 register field descriptions field description 7:0 db[7:0] data bits 7:0
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 321 rev 1.09 10.3.3.3 data length register (dlr) this register keeps the data length ?ld of the can frame. 10.3.3.4 transmit buffer priority register (tbpr) this register de?es the local priority of the associated message buffer. the local priority is used for the internal prioritization process of the mscan and is de?ed to be highest for the smallest binary number. the mscan implements the following internal prioritization mechanisms: all transmission buffers with a cleared txex ?g participate in the prioritization immediately before the sof (start of frame) is sent. the transmission buffer with the lowest local priority ?ld wins the prioritization. module base + 0x00xb 76543210 r dlc3 dlc2 dlc1 dlc0 w reset: xxxxxxxx = unused; always read ? figure 10-34. data length register (dlr) ?extended identi?r mapping table 10-31. dlr register field descriptions field description 3:0 dlc[3:0] data length code bits the data length code contains the number of bytes (data byte count) of the respective message. during the transmission of a remote frame, the data length code is transmitted as programmed while the number of transmitted data bytes is always 0. the data byte count ranges from 0 to 8 for a data frame. table 10-32 shows the effect of setting the dlc bits. table 10-32. data length codes data length code data byte count dlc3 dlc2 dlc1 dlc0 00000 00011 00102 00113 01004 01015 01106 01117 10008
chapter 10 freescales scalable controller area network (s12mscanv2) 322 mc9s12q128 freescale semiconductor rev 1.09 in cases of more than one buffer having the same lowest priority, the message buffer with the lower index number wins. read: anytime when txex ?g is set (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 10.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. write: anytime when txex ?g is set (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 10.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. 10.3.3.5 time stamp register (tsrh?srl) if the time bit is enabled, the mscan will write a time stamp to the respective registers in the active transmit or receive buffer right after the eof of a valid message on the can bus (see section 10.3.2.1, ?scan control register 0 (canctl0) ?. in case of a transmission, the cpu can only read the time stamp after the respective transmit buffer has been ?gged empty. the timer value, which is used for stamping, is taken from a free running internal can bit clock. a timer overrun is not indicated by the mscan. the timer is reset (all bits set to 0) during initialization mode. the cpu can only read the time stamp registers. module base + 0xxxxd 76543210 r prio7 prio6 prio5 prio4 prio3 prio2 prio1 prio0 w reset: 00000000 figure 10-35. transmit buffer priority register (tbpr) module base + 0xxxxe 76543210 r tsr15 tsr14 tsr13 tsr12 tsr11 tsr10 tsr9 tsr8 w reset: xxxxxxxx figure 10-36. time stamp register ?high byte (tsrh) module base + 0xxxxf 76543210 r tsr7 tsr6 tsr5 tsr4 tsr3 tsr2 tsr1 tsr0 w reset: xxxxxxxx figure 10-37. time stamp register ?low byte (tsrl)
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 323 rev 1.09 read: anytime when txex ?g is set (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 10.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. write: unimplemented 10.4 functional description 10.4.1 general this section provides a complete functional description of the mscan. it describes each of the features and modes listed in the introduction.
chapter 10 freescales scalable controller area network (s12mscanv2) 324 mc9s12q128 freescale semiconductor rev 1.09 10.4.2 message storage figure 10-38. user model for message buffer organization mscan facilitates a sophisticated message storage system which addresses the requirements of a broad range of network applications. mscan rx0 rx1 can receive / transmit engine cpu12 memory mapped i/o cpu bus mscan tx2 txe2 prio receiver transmitter rxbg txbg tx0 txe0 prio txbg tx1 prio txe1 txfg cpu bus rx2 rx3 rx4 rxf rxfg
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 325 rev 1.09 10.4.2.1 message transmit background modern application layer software is built upon two fundamental assumptions: any can node is able to send out a stream of scheduled messages without releasing the can bus between the two messages. such nodes arbitrate for the can bus immediately after sending the previous message and only release the can bus in case of lost arbitration. the internal message queue within any can node is organized such that the highest priority message is sent out ?st, if more than one message is ready to be sent. the behavior described in the bullets above cannot be achieved with a single transmit buffer. that buffer must be reloaded immediately after the previous message is sent. this loading process lasts a ?ite amount of time and must be completed within the inter-frame sequence (ifs) to be able to send an uninterrupted stream of messages. even if this is feasible for limited can bus speeds, it requires that the cpu reacts with short latencies to the transmit interrupt. a double buffer scheme de-couples the reloading of the transmit buffer from the actual message sending and, therefore, reduces the reactiveness requirements of the cpu. problems can arise if the sending of a message is ?ished while the cpu re-loads the second buffer. no buffer would then be ready for transmission, and the can bus would be released. at least three transmit buffers are required to meet the ?st of the above requirements under all circumstances. the mscan has three transmit buffers. the second requirement calls for some sort of internal prioritization which the mscan implements with the ?ocal priority?concept described in section 10.4.2.2, ?ransmit structures . 10.4.2.2 transmit structures the mscan triple transmit buffer scheme optimizes real-time performance by allowing multiple messages to be set up in advance. the three buffers are arranged as shown in figure 10-38 . all three buffers have a 13-byte data structure similar to the outline of the receive buffers (see section 10.3.3, ?rogrammers model of message storage ?. an additional section 10.3.3.4, ?ransmit buffer priority register (tbpr) contains an 8-bit local priority ?ld (prio) (see section 10.3.3.4, ?ransmit buffer priority register (tbpr) ?. the remaining two bytes are used for time stamping of a message, if required (see section 10.3.3.5, ?ime stamp register (tsrh?srl) ?. to transmit a message, the cpu must identify an available transmit buffer, which is indicated by a set transmitter buffer empty (txex) ?g (see section 10.3.2.7, ?scan transmitter flag register (cantflg) ?. if a transmit buffer is available, the cpu must set a pointer to this buffer by writing to the cantbsel register (see section 10.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. this makes the respective buffer accessible within the cantxfg address space (see section 10.3.3, ?rogrammers model of message storage ?. the algorithmic feature associated with the cantbsel register simpli?s the transmit buffer selection. in addition, this scheme makes the handler software simpler because only one address area is applicable for the transmit process, and the required address space is minimized. the cpu then stores the identi?r, the control bits, and the data content into one of the transmit buffers. finally, the buffer is ?gged as ready for transmission by clearing the associated txe ?g.
chapter 10 freescales scalable controller area network (s12mscanv2) 326 mc9s12q128 freescale semiconductor rev 1.09 the mscan then schedules the message for transmission and signals the successful transmission of the buffer by setting the associated txe ?g. a transmit interrupt (see section 10.4.7.2, ?ransmit interrupt ? is generated 1 when txex is set and can be used to drive the application software to re-load the buffer. if more than one buffer is scheduled for transmission when the can bus becomes available for arbitration, the mscan uses the local priority setting of the three buffers to determine the prioritization. for this purpose, every transmit buffer has an 8-bit local priority ?ld (prio). the application software programs this ?ld when the message is set up. the local priority re?cts the priority of this particular message relative to the set of messages being transmitted from this node. the lowest binary value of the prio ?ld is de?ed to be the highest priority. the internal scheduling process takes place whenever the mscan arbitrates for the can bus. this is also the case after the occurrence of a transmission error. when a high priority message is scheduled by the application software, it may become necessary to abort a lower priority message in one of the three transmit buffers. because messages that are already in transmission cannot be aborted, the user must request the abort by setting the corresponding abort request bit (abtrq) (see section 10.3.2.9, ?scan transmitter message abort request register (cantarq) ?) the mscan then grants the request, if possible, by: 1. setting the corresponding abort acknowledge ?g (abtak) in the cantaak register. 2. setting the associated txe ?g to release the buffer. 3. generating a transmit interrupt. the transmit interrupt handler software can determine from the setting of the abtak ?g whether the message was aborted (abtak = 1) or sent (abtak = 0). 10.4.2.3 receive structures the received messages are stored in a ve stage input fifo. the ve message buffers are alternately mapped into a single memory area (see figure 10-38 ). the background receive buffer (rxbg) is exclusively associated with the mscan, but the foreground receive buffer (rxfg) is addressable by the cpu (see figure 10-38 ). this scheme simpli?s the handler software because only one address area is applicable for the receive process. all receive buffers have a size of 15 bytes to store the can control bits, the identi?r (standard or extended), the data contents, and a time stamp, if enabled (see section 10.3.3, ?rogrammers model of message storage ?. the receiver full ?g (rxf) (see section 10.3.2.5, ?scan receiver flag register (canrflg) ? signals the status of the foreground receive buffer. when the buffer contains a correctly received message with a matching identi?r, this ?g is set. on reception, each message is checked to see whether it passes the ?ter (see section 10.4.3, ?denti?r acceptance filter ? and simultaneously is written into the active rxbg. after successful reception of a valid message, the mscan shifts the content of rxbg into the receiver fifo 2 , sets the rxf ?g, and generates a receive interrupt (see section 10.4.7.3, ?eceive interrupt ? to the cpu 3 . the users receive handler must read the received message from the rxfg and then reset the rxf ?g to acknowledge the interrupt and to release the foreground buffer. a new message, which can follow immediately after the ifs ?ld of the can frame, is received into the next available rxbg. if the mscan receives an invalid 1. the transmit interrupt occurs only if not masked. a polling scheme can be applied on txex also. 2. only if the rxf ?g is not set. 3. the receive interrupt occurs only if not masked. a polling scheme can be applied on rxf also.
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 327 rev 1.09 message in its rxbg (wrong identi?r, transmission errors, etc.) the actual contents of the buffer will be over-written by the next message. the buffer will then not be shifted into the fifo. when the mscan module is transmitting, the mscan receives its own transmitted messages into the background receive buffer, rxbg, but does not shift it into the receiver fifo, generate a receive interrupt, or acknowledge its own messages on the can bus. the exception to this rule is in loopback mode (see section 10.3.2.2, ?scan control register 1 (canctl1) ? where the mscan treats its own messages exactly like all other incoming messages. the mscan receives its own transmitted messages in the event that it loses arbitration. if arbitration is lost, the mscan must be prepared to become a receiver. an overrun condition occurs when all receive message buffers in the fifo are ?led with correctly received messages with accepted identi?rs and another message is correctly received from the can bus with an accepted identi?r. the latter message is discarded and an error interrupt with overrun indication is generated if enabled (see section 10.4.7.5, ?rror interrupt ?. the mscan remains able to transmit messages while the receiver fifo being ?led, but all incoming messages are discarded. as soon as a receive buffer in the fifo is available again, new valid messages will be accepted. 10.4.3 identi?r acceptance filter the mscan identi?r acceptance registers (see section 10.3.2.12, ?scan identi?r acceptance control register (canidac) ? de?e the acceptable patterns of the standard or extended identi?r (id[10:0] or id[28:0]). any of these bits can be marked ?ont care?in the mscan identi?r mask registers (see section 10.3.2.17, ?scan identi?r mask registers (canidmr0?anidmr7) ?. a ?ter hit is indicated to the application software by a set receive buffer full ?g (rxf = 1) and three bits in the canidac register (see section 10.3.2.12, ?scan identi?r acceptance control register (canidac) ?. these identi?r hit ?gs (idhit[2:0]) clearly identify the ?ter section that caused the acceptance. they simplify the application softwares task to identify the cause of the receiver interrupt. if more than one hit occurs (two or more ?ters match), the lower hit has priority. a very ?xible programmable generic identi?r acceptance ?ter has been introduced to reduce the cpu interrupt loading. the ?ter is programmable to operate in four different modes (see bosch can 2.0a/b protocol speci?ation): two identi?r acceptance ?ters, each to be applied to: the full 29 bits of the extended identi?r and to the following bits of the can 2.0b frame: remote transmission request (rtr) identi?r extension (ide) substitute remote request (srr) the 11 bits of the standard identi?r plus the rtr and ide bits of the can 2.0a/b messages 1 . this mode implements two ?ters for a full length can 2.0b compliant extended identi?r. figure 10-39 shows how the ?st 32-bit ?ter bank (canidar0?anidar3, canidmr0?anidmr3) produces a ?ter 0 hit. similarly, the second ?ter bank (canidar4?anidar7, canidmr4?anidmr7) produces a ?ter 1 hit. four identi?r acceptance ?ters, each to be applied to 1. although this mode can be used for standard identifiers, it is recommended to use the four or eight identifier acceptance filters for standard identifiers
chapter 10 freescales scalable controller area network (s12mscanv2) 328 mc9s12q128 freescale semiconductor rev 1.09 a) the 14 most signi?ant bits of the extended identi?r plus the srr and ide bits of can 2.0b messages or b) the 11 bits of the standard identi?r, the rtr and ide bits of can 2.0a/b messages. figure 10-40 shows how the ?st 32-bit ?ter bank (canidar0?anida3, canidmr0?canidmr) produces ?ter 0 and 1 hits. similarly, the second ?ter bank (canidar4?anidar7, canidmr4?anidmr7) produces ?ter 2 and 3 hits. eight identi?r acceptance ?ters, each to be applied to the ?st 8 bits of the identi?r. this mode implements eight independent ?ters for the ?st 8 bits of a can 2.0a/b compliant standard identi?r or a can 2.0b compliant extended identi?r. figure 10-41 shows how the ?st 32-bit ?ter bank (canidar0?anidar3, canidmr0?anidmr3) produces ?ter 0 to 3 hits. similarly, the second ?ter bank (canidar4?anidar7, canidmr4?anidmr7) produces ?ter 4 to 7 hits. closed ?ter. no can message is copied into the foreground buffer rxfg, and the rxf ?g is never set. figure 10-39. 32-bit maskable identi?r acceptance filter id28 id21 idr0 id10 id3 idr0 id20 id15 idr1 id2 ide idr1 id14 id7 idr2 id10 id3 idr2 id6 rtr idr3 id10 id3 idr3 ac7 ac0 canidar0 am7 am0 canidmr0 ac7 ac0 canidar1 am7 am0 canidmr1 ac7 ac0 canidar2 am7 am0 canidmr2 ac7 ac0 canidar3 am7 am0 canidmr3 id accepted (filter 0 hit) can 2.0b extended identi?r can 2.0a/b standard identi?r
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 329 rev 1.09 figure 10-40. 16-bit maskable identi?r acceptance filters id28 id21 idr0 id10 id3 idr0 id20 id15 idr1 id2 ide idr1 id14 id7 idr2 id10 id3 idr2 id6 rtr idr3 id10 id3 idr3 ac7 ac0 canidar0 am7 am0 canidmr0 ac7 ac0 canidar1 am7 am0 canidmr1 id accepted (filter 0 hit) ac7 ac0 canidar2 am7 am0 canidmr2 ac7 ac0 canidar3 am7 am0 canidmr3 id accepted (filter 1 hit) can 2.0b extended identi?r can 2.0a/b standard identi?r
chapter 10 freescales scalable controller area network (s12mscanv2) 330 mc9s12q128 freescale semiconductor rev 1.09 figure 10-41. 8-bit maskable identi?r acceptance filters can 2.0b extended identi?r can 2.0a/b standard identi?r ac7 ac0 cidar3 am7 am0 cidmr3 id accepted (filter 3 hit) ac7 ac0 cidar2 am7 am0 cidmr2 id accepted (filter 2 hit) ac7 ac0 cidar1 am7 am0 cidmr1 id accepted (filter 1 hit) id28 id21 idr0 id10 id3 idr0 id20 id15 idr1 id2 ide idr1 id14 id7 idr2 id10 id3 idr2 id6 rtr idr3 id10 id3 idr3 ac7 ac0 cidar0 am7 am0 cidmr0 id accepted (filter 0 hit)
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 331 rev 1.09 10.4.3.1 protocol violation protection the mscan protects the user from accidentally violating the can protocol through programming errors. the protection logic implements the following features: the receive and transmit error counters cannot be written or otherwise manipulated. all registers which control the con?uration of the mscan cannot be modi?d while the mscan is on-line. the mscan has to be in initialization mode. the corresponding initrq/initak handshake bits in the canctl0/canctl1 registers (see section 10.3.2.1, ?scan control register 0 (canctl0) ? serve as a lock to protect the following registers: mscan control 1 register (canctl1) mscan bus timing registers 0 and 1 (canbtr0, canbtr1) mscan identi?r acceptance control register (canidac) mscan identi?r acceptance registers (canidar0?anidar7) mscan identi?r mask registers (canidmr0?anidmr7) the txcan pin is immediately forced to a recessive state when the mscan goes into the power down mode or initialization mode (see section 10.4.5.6, ?scan power down mode , and section 10.4.5.5, ?scan initialization mode ?. the mscan enable bit (cane) is writable only once in normal system operation modes, which provides further protection against inadvertently disabling the mscan. 10.4.3.2 clock system figure 10-42 shows the structure of the mscan clock generation circuitry. figure 10-42. mscan clocking scheme the clock source bit (clksrc) in the canctl1 register ( 10.3.2.2/10-294 ) de?es whether the internal canclk is connected to the output of a crystal oscillator (oscillator clock) or to the bus clock. the clock source has to be chosen such that the tight oscillator tolerance requirements (up to 0.4%) of the can protocol are met. additionally, for high can bus rates (1 mbps), a 45% to 55% duty cycle of the clock is required. bus clock oscillator clock mscan canclk clksrc clksrc prescaler (1 .. 64) time quanta clock (tq)
chapter 10 freescales scalable controller area network (s12mscanv2) 332 mc9s12q128 freescale semiconductor rev 1.09 if the bus clock is generated from a pll, it is recommended to select the oscillator clock rather than the bus clock due to jitter considerations, especially at the faster can bus rates. for microcontrollers without a clock and reset generator (crg), canclk is driven from the crystal oscillator (oscillator clock). a programmable prescaler generates the time quanta (tq) clock from canclk. a time quantum is the atomic unit of time handled by the mscan. eqn. 10-2 a bit time is subdivided into three segments as described in the bosch can speci?ation. (see figure 10- 43 ): sync_seg: this segment has a ?ed length of one time quantum. signal edges are expected to happen within this section. time segment 1: this segment includes the prop_seg and the phase_seg1 of the can standard. it can be programmed by setting the parameter tseg1 to consist of 4 to 16 time quanta. time segment 2: this segment represents the phase_seg2 of the can standard. it can be programmed by setting the tseg2 parameter to be 2 to 8 time quanta long. eqn. 10-3 figure 10-43. segments within the bit time tq f canclk prescaler value ( ) ---------------------------------------------------- -- = bit rate f tq number of time quanta () -------------------------------------------------------------------------------- - = sync_seg time segment 1 time segment 2 1 4 ... 16 2 ... 8 8 ... 25 time quanta = 1 bit time nrz signal sample point (single or triple sampling) (prop_seg + phase_seg1) (phase_seg2) transmit point
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 333 rev 1.09 the synchronization jump width (see the bosch can speci?ation for details) can be programmed in a range of 1 to 4 time quanta by setting the sjw parameter. the sync_seg, tseg1, tseg2, and sjw parameters are set by programming the mscan bus timing registers (canbtr0, canbtr1) (see section 10.3.2.3, ?scan bus timing register 0 (canbtr0) and section 10.3.2.4, ?scan bus timing register 1 (canbtr1) ?. table 10-34 gives an overview of the can compliant segment settings and the related parameter values. note it is the users responsibility to ensure the bit time settings are in compliance with the can standard. 10.4.4 modes of operation 10.4.4.1 normal modes the mscan module behaves as described within this speci?ation in all normal system operation modes. 10.4.4.2 special modes the mscan module behaves as described within this speci?ation in all special system operation modes. table 10-33. time segment syntax syntax description sync_seg system expects transitions to occur on the can bus during this period. transmit point a node in transmit mode transfers a new value to the can bus at this point. sample point a node in receive mode samples the can bus at this point. if the three samples per bit option is selected, then this point marks the position of the third sample. table 10-34. can standard compliant bit time segment settings time segment 1 tseg1 time segment 2 tseg2 synchronization jump width sjw 5 .. 10 4 .. 9 2 1 1 .. 2 0 .. 1 4 .. 11 3 .. 10 3 2 1 .. 3 0 .. 2 5 .. 12 4 .. 11 4 3 1 .. 4 0 .. 3 6 .. 13 5 .. 12 5 4 1 .. 4 0 .. 3 7 .. 14 6 .. 13 6 5 1 .. 4 0 .. 3 8 .. 15 7 .. 14 7 6 1 .. 4 0 .. 3 9 .. 16 8 .. 15 8 7 1 .. 4 0 .. 3
chapter 10 freescales scalable controller area network (s12mscanv2) 334 mc9s12q128 freescale semiconductor rev 1.09 10.4.4.3 emulation modes in all emulation modes, the mscan module behaves just like normal system operation modes as described within this speci?ation. 10.4.4.4 listen-only mode in an optional can bus monitoring mode (listen-only), the can node is able to receive valid data frames and valid remote frames, but it sends only ?ecessive?bits on the can bus. in addition, it cannot start a transmision. if the mac sub-layer is required to send a ?ominant bit (ack bit, overload ?g, or active error ?g), the bit is rerouted internally so that the mac sub-layer monitors this ?ominant bit, although the can bus may remain in recessive state externally. 10.4.4.5 security modes the mscan module has no security features. 10.4.5 low-power options if the mscan is disabled (cane = 0), the mscan clocks are stopped for power saving. if the mscan is enabled (cane = 1), the mscan has two additional modes with reduced power consumption, compared to normal mode: sleep and power down mode. in sleep mode, power consumption is reduced by stopping all clocks except those to access the registers from the cpu side. in power down mode, all clocks are stopped and no power is consumed. table 10-35 summarizes the combinations of mscan and cpu modes. a particular combination of modes is entered by the given settings on the cswai and slprq/slpak bits. for all modes, an mscan wake-up interrupt can occur only if the mscan is in sleep mode (slprq = 1 and slpak = 1), wake-up functionality is enabled (wupe = 1), and the wake-up interrupt is enabled (wupie = 1).
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 335 rev 1.09 10.4.5.1 operation in run mode as shown in table 10-35 , only mscan sleep mode is available as low power option when the cpu is in run mode. 10.4.5.2 operation in wait mode the wai instruction puts the mcu in a low power consumption stand-by mode. if the cswai bit is set, additional power can be saved in power down mode because the cpu clocks are stopped. after leaving this power down mode, the mscan restarts its internal controllers and enters normal mode again. while the cpu is in wait mode, the mscan can be operated in normal mode and generate interrupts (registers can be accessed via background debug mode). the mscan can also operate in any of the low- power modes depending on the values of the slprq/slpak and cswai bits as seen in table 10-35 . 10.4.5.3 operation in stop mode the stop instruction puts the mcu in a low power consumption stand-by mode. in stop mode, the mscan is set in power down mode regardless of the value of the slprq/slpak and cswai bits table 10-35 . 10.4.5.4 mscan sleep mode the cpu can request the mscan to enter this low power mode by asserting the slprq bit in the canctl0 register. the time when the mscan enters sleep mode depends on a ?ed synchronization delay and its current activity: table 10-35. cpu vs. mscan operating modes cpu mode mscan mode normal reduced power consumption sleep power down disabled (cane=0) run cswai = x (1) slprq = 0 slpak = 0 1. ??means don? care. cswai = x slprq = 1 slpak = 1 cswai = x slprq = x slpak = x wait cswai = 0 slprq = 0 slpak = 0 cswai = 0 slprq = 1 slpak = 1 cswai = 1 slprq = x slpak = x cswai = x slprq = x slpak = x stop cswai = x slprq = x slpak = x cswai = x slprq = x slpak = x
chapter 10 freescales scalable controller area network (s12mscanv2) 336 mc9s12q128 freescale semiconductor rev 1.09 if there are one or more message buffers scheduled for transmission (txex = 0), the mscan will continue to transmit until all transmit message buffers are empty (txex = 1, transmitted successfully or aborted) and then goes into sleep mode. if the mscan is receiving, it continues to receive and goes into sleep mode as soon as the can bus next becomes idle. if the mscan is neither transmitting nor receiving, it immediately goes into sleep mode. figure 10-44. sleep request / acknowledge cycle note the application software must avoid setting up a transmission (by clearing one or more txex ?g(s)) and immediately request sleep mode (by setting slprq). whether the mscan starts transmitting or goes into sleep mode directly depends on the exact sequence of operations. if sleep mode is active, the slprq and slpak bits are set ( figure 10-44 ). the application software must use slpak as a handshake indication for the request (slprq) to go into sleep mode. when in sleep mode (slprq = 1 and slpak = 1), the mscan stops its internal clocks. however, clocks that allow register accesses from the cpu side continue to run. if the mscan is in bus-off state, it stops counting the 128 occurrences of 11 consecutive recessive bits due to the stopped clocks. the txcan pin remains in a recessive state. if rxf = 1, the message can be read and rxf can be cleared. shifting a new message into the foreground buffer of the receiver fifo (rxfg) does not take place while in sleep mode. it is possible to access the transmit buffers and to clear the associated txe ?gs. no message abort takes place while in sleep mode. if the wupe bit in canclt0 is not asserted, the mscan will mask any activity it detects on can. the rxcan pin is therefore held internally in a recessive state. this locks the mscan in sleep mode ( figure 10-45 ). wupe must be set before entering sleep mode to take effect. sync sync bus cloc k domain can cloc k domain mscan in sleep mode cpu sleep request slprq flag slpak flag slprq sync. slpak sync. slprq slpak
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 337 rev 1.09 the mscan is able to leave sleep mode (wake up) only when: can bus activity occurs and wupe = 1 or the cpu clears the slprq bit note the cpu cannot clear the slprq bit before sleep mode (slprq = 1 and slpak = 1) is active. after wake-up, the mscan waits for 11 consecutive recessive bits to synchronize to the can bus. as a consequence, if the mscan is woken-up by a can frame, this frame is not received. the receive message buffers (rxfg and rxbg) contain messages if they were received before sleep mode was entered. all pending actions will be executed upon wake-up; copying of rxbg into rxfg, message aborts and message transmissions. if the mscan remains in bus-off state after sleep mode was exited, it continues counting the 128 occurrences of 11 consecutive recessive bits. figure 10-45. simpli?d state transitions for entering/leaving sleep mode wait idle tx/rx message active can activity can activity & sleep slprq startup for idle (can activity & wupe) | (can activity & wupe) | slprq can activity can activity can activity & can activity slprq slprq can activity
chapter 10 freescales scalable controller area network (s12mscanv2) 338 mc9s12q128 freescale semiconductor rev 1.09 10.4.5.5 mscan initialization mode in initialization mode, any on-going transmission or reception is immediately aborted and synchronization to the can bus is lost, potentially causing can protocol violations. to protect the can bus system from fatal consequences of violations, the mscan immediately drives the txcan pin into a recessive state. note the user is responsible for ensuring that the mscan is not active when initialization mode is entered. the recommended procedure is to bring the mscan into sleep mode (slprq = 1 and slpak = 1) before setting the initrq bit in the canctl0 register. otherwise, the abort of an on-going message can cause an error condition and can impact other can bus devices. in initialization mode, the mscan is stopped. however, interface registers remain accessible. this mode is used to reset the canctl0, canrflg, canrier, cantflg, cantier, cantarq, cantaak, and cantbsel registers to their default values. in addition, the mscan enables the con?uration of the canbtr0, canbtr1 bit timing registers; canidac; and the canidar, canidmr message ?ters. see section 10.3.2.1, ?scan control register 0 (canctl0) , for a detailed description of the initialization mode. figure 10-46. initialization request/acknowledge cycle due to independent clock domains within the mscan, initrq must be synchronized to all domains by using a special handshake mechanism. this handshake causes additional synchronization delay (see section figure 10-46., ?nitialization request/acknowledge cycle ?. if there is no message transfer ongoing on the can bus, the minimum delay will be two additional bus clocks and three additional can clocks. when all parts of the mscan are in initialization mode, the initak ?g is set. the application software must use initak as a handshake indication for the request (initrq) to go into initialization mode. note the cpu cannot clear initrq before initialization mode (initrq = 1 and initak = 1) is active. sync sync bus cloc k domain can cloc k domain cpu init request init flag initak flag initrq sync. initak sync. initrq initak
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 339 rev 1.09 10.4.5.6 mscan power down mode the mscan is in power down mode ( table 10-35 ) when cpu is in stop mode or cpu is in wait mode and the cswai bit is set when entering the power down mode, the mscan immediately stops all ongoing transmissions and receptions, potentially causing can protocol violations. to protect the can bus system from fatal consequences of violations to the above rule, the mscan immediately drives the txcan pin into a recessive state. note the user is responsible for ensuring that the mscan is not active when power down mode is entered. the recommended procedure is to bring the mscan into sleep mode before the stop or wai instruction (if cswai is set) is executed. otherwise, the abort of an ongoing message can cause an error condition and impact other can bus devices. in power down mode, all clocks are stopped and no registers can be accessed. if the mscan was not in sleep mode before power down mode became active, the module performs an internal recovery cycle after powering up. this causes some ?ed delay before the module enters normal mode again. 10.4.5.7 programmable wake-up function the mscan can be programmed to wake up the mscan as soon as can bus activity is detected (see control bit wupe in section 10.3.2.1, ?scan control register 0 (canctl0) ?. the sensitivity to existing can bus action can be modi?d by applying a low-pass ?ter function to the rxcan input line while in sleep mode (see control bit wupm in section 10.3.2.2, ?scan control register 1 (canctl1) ?. this feature can be used to protect the mscan from wake-up due to short glitches on the can bus lines. such glitches can result from?or example?lectromagnetic interference within noisy environments. 10.4.6 reset initialization the reset state of each individual bit is listed in section 10.3.2, ?egister descriptions , which details all the registers and their bit-?lds. 10.4.7 interrupts this section describes all interrupts originated by the mscan. it documents the enable bits and generated ?gs. each interrupt is listed and described separately.
chapter 10 freescales scalable controller area network (s12mscanv2) 340 mc9s12q128 freescale semiconductor rev 1.09 10.4.7.1 description of interrupt operation the mscan supports four interrupt vectors (see table 10-36 ), any of which can be individually masked (for details see sections from section 10.3.2.6, ?scan receiver interrupt enable register (canrier) , to section 10.3.2.8, ?scan transmitter interrupt enable register (cantier) ?. note the dedicated interrupt vector addresses are de?ed in the resets and interrupts chapter. 10.4.7.2 transmit interrupt at least one of the three transmit buffers is empty (not scheduled) and can be loaded to schedule a message for transmission. the txex ?g of the empty message buffer is set. 10.4.7.3 receive interrupt a message is successfully received and shifted into the foreground buffer (rxfg) of the receiver fifo. this interrupt is generated immediately after receiving the eof symbol. the rxf ?g is set. if there are multiple messages in the receiver fifo, the rxf ?g is set as soon as the next message is shifted to the foreground buffer. 10.4.7.4 wake-up interrupt a wake-up interrupt is generated if activity on the can bus occurs during mscn internal sleep mode. wupe (see section 10.3.2.1, ?scan control register 0 (canctl0) ? must be enabled. 10.4.7.5 error interrupt an error interrupt is generated if an overrun of the receiver fifo, error, warning, or bus-off condition occurrs. section 10.3.2.5, ?scan receiver flag register (canrflg) indicates one of the following conditions: overrun an overrun condition of the receiver fifo as described in section 10.4.2.3, ?eceive structures , occurred. can status change ?the actual value of the transmit and receive error counters control the can bus state of the mscan. as soon as the error counters skip into a critical range (tx/rx- warning, tx/rx-error, bus-off) the mscan ?gs an error condition. the status change, which caused the error condition, is indicated by the tstat and rstat ?gs (see section 10.3.2.5, table 10-36. interrupt vectors interrupt source ccr mask local enable wake-up interrupt (wupif) i bit canrier (wupie) error interrupts interrupt (cscif, ovrif) i bit canrier (cscie, ovrie) receive interrupt (rxf) i bit canrier (rxfie) transmit interrupts (txe[2:0]) i bit cantier (txeie[2:0])
chapter 10 freescales scalable controller area network (s12mscanv2) freescale semiconductor mc9s12q128 341 rev 1.09 ?scan receiver flag register (canrflg) ?and section 10.3.2.6, ?scan receiver interrupt enable register (canrier) ?. 10.4.7.6 interrupt acknowledge interrupts are directly associated with one or more status ?gs in either the section 10.3.2.5, ?scan receiver flag register (canrflg) ?or the section 10.3.2.7, ?scan transmitter flag register (cantflg) . interrupts are pending as long as one of the corresponding ?gs is set. the ?gs in canrflg and cantflg must be reset within the interrupt handler to handshake the interrupt. the ?gs are reset by writing a 1 to the corresponding bit position. a ?g cannot be cleared if the respective condition prevails. note it must be guaranteed that the cpu clears only the bit causing the current interrupt. for this reason, bit manipulation instructions (bset) must not be used to clear interrupt ?gs. these instructions may cause accidental clearing of interrupt ?gs which are set after entering the current interrupt service routine. 10.4.7.7 recovery from stop or wait the mscan can recover from stop or wait via the wake-up interrupt. this interrupt can only occur if the mscan was in sleep mode (slprq = 1 and slpak = 1) before entering power down mode, the wake- up option is enabled (wupe = 1), and the wake-up interrupt is enabled (wupie = 1). 10.5 initialization/application information 10.5.1 mscan initialization the procedure to initially start up the mscan module out of reset is as follows: 1. assert cane 2. write to the con?uration registers in initialization mode 3. clear initrq to leave initialization mode and enter normal mode if the con?uration of registers which are writable in initialization mode needs to be changed only when the mscan module is in normal mode: 1. bring the module into sleep mode by setting slprq and awaiting slpak to assert after the can bus becomes idle. 2. enter initialization mode: assert initrq and await initak 3. write to the con?uration registers in initialization mode 4. clear initrq to leave initialization mode and continue in normal mode
chapter 10 freescales scalable controller area network (s12mscanv2) 342 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 343 rev 1.09 chapter 11 oscillator (oscv2) block description 11.1 introduction the oscv2 module provides two alternative oscillator concepts: a low noise and low power colpitts oscillator with amplitude limitation control (alc) a robust full swing pierce oscillator with the possibility to feed in an external square wave 11.1.1 features the colpitts oscv2 option provides the following features: amplitude limitation control (alc) loop: low power consumption and low current induced rf emission sinusoidal waveform with low rf emission low crystal stress (an external damping resistor is not required) normal and low amplitude mode for further reduction of power and emission an external biasing resistor is not required the pierce osc option provides the following features: wider high frequency operation range no dc voltage applied across the crystal full rail-to-rail (2.5 v nominal) swing oscillation with low em susceptibility fast start up common features: clock monitor (cm) operation from the v ddpll 2.5 v (nominal) supply rail 11.1.2 modes of operation two modes of operation exist: amplitude limitation controlled colpitts oscillator mode suitable for power and emission critical applications full swing pierce oscillator mode that can also be used to feed in an externally generated square wave suitable for high frequency operation and harsh environments
chapter 11 oscillator (oscv2) block description 344 mc9s12q128 freescale semiconductor rev 1.09 11.2 external signal description this section lists and describes the signals that connect off chip. 11.2.1 v ddpll and v sspll ?pll operating voltage, pll ground these pins provide the operating voltage (v ddpll ) and ground (v sspll ) for the oscv2 circuitry. this allows the supply voltage to the oscv2 to be independently bypassed. 11.2.2 extal and xtal ?clock/crystal source pins these pins provide the interface for either a crystal or a cmos compatible clock to control the internal clock generator circuitry. extal is the external clock input or the input to the crystal oscillator ampli?r. xtal is the output of the crystal oscillator ampli?r. all the mcu internal system clocks are derived from the extal input frequency. in full stop mode (pstp = 0) the extal pin is pulled down by an internal resistor of typical 200 k ? . note freescale semiconductor recommends an evaluation of the application board and chosen resonator or crystal by the resonator or crystal supplier . the crystal circuit is changed from standard. the colpitts circuit is not suited for overtone resonators and crystals. figure 11-1. colpitts oscillator connections (xclks = 0) note the pierce circuit is not suited for overtone resonators and crystals without a careful component selection. mcu c2 extal xtal v sspll c1 cdc* crystal or ceramic resonator * due to the nature of a translated ground colpitts oscillator a dc voltage bias is applied to the crystal. please contact the crystal manufacturer for crystal dc bias conditions and recommended capacitor value cdc.
chapter 11 oscillator (oscv2) block description freescale semiconductor mc9s12q128 345 rev 1.09 figure 11-2. pierce oscillator connections (xclks = 1) figure 11-3. external clock connections (xclks = 1) 11.2.3 xclks ?colpitts/pierce oscillator selection signal the xclks is an input signal which controls whether a crystal in combination with the internal colpitts (low power) oscillator is used or whether the pierce oscillator/external clock circuitry is used. the xclks signal is sampled during reset with the rising edge of reset. table 11-1 lists the state coding of the sampled xclks signal. refer to the device overview chapter for polarity of the xclks pin. table 11-1. clock selection based on xclks xclks description 0 colpitts oscillator selected 1 pierce oscillator/external clock selected mcu extal xtal rs* rb v sspll crystal or ceramic resonator c4 c3 * rs can be zero (shorted) when used with higher frequency crystals. refer to manufacturers data. mcu extal xtal cmos-compatible external oscillator not connected (v ddpll level)
chapter 11 oscillator (oscv2) block description 346 mc9s12q128 freescale semiconductor rev 1.09 11.3 memory map and register de?ition the crg contains the registers and associated bits for controlling and monitoring the oscv2 module. 11.4 functional description the oscv2 block has two external pins, extal and xtal. the oscillator input pin, extal, is intended to be connected to either a crystal or an external clock source. the selection of colpitts oscillator or pierce oscillator/external clock depends on the xclks signal which is sampled during reset. the xtal pin is an output signal that provides crystal circuit feedback. a buffered extal signal, oscclk, becomes the internal reference clock. to improve noise immunity, the oscillator is powered by the v ddpll and v sspll power supply pins. the pierce oscillator can be used for higher frequencies compared to the low power colpitts oscillator. 11.4.1 amplitude limitation control (alc) the colpitts oscillator is equipped with a feedback system which does not waste current by generating harmonics. its con?uration is ?olpitts oscillator with translated ground.?the transconductor used is driven by a current source under the control of a peak detector which will measure the amplitude of the ac signal appearing on extal node in order to implement an amplitude limitation control (alc) loop. the alc loop is in charge of reducing the quiescent current in the transconductor as a result of an increase in the oscillation amplitude. the oscillation amplitude can be limited to two values. the normal amplitude which is intended for non power saving modes and a small amplitude which is intended for low power operation modes. please refer to the crg block description chapter for the control and assignment of the amplitude value to operation modes. 11.4.2 clock monitor (cm) the clock monitor circuit is based on an internal resistor-capacitor (rc) time delay so that it can operate without any mcu clocks. if no oscclk edges are detected within this rc time delay, the clock monitor indicates a failure which asserts self clock mode or generates a system reset depending on the state of scme bit. if the clock monitor is disabled or the presence of clocks is detected no failure is indicated.the clock monitor function is enabled/disabled by the cme control bit, described in the crg block description chapter. 11.5 interrupts oscv2 contains a clock monitor, which can trigger an interrupt or reset. the control bits and status bits for the clock monitor are described in the crg block description chapter.
freescale semiconductor mc9s12q128 347 rev 1.09 chapter 12 pulse-width modulator (pwm8b4c) block description 12.1 introduction the pulse width modulation (pwm) de?ition is based on the hc12 pwm de?itions. the pwm8b4c module contains the basic features from the hc11 with some of the enhancements incorporated on the hc12, that is center aligned output mode and four available clock sources. the pwm8b4c module has four channels with independent control of left and center aligned outputs on each channel. each of the pwm channels has a programmable period and duty cycle as well as a dedicated counter. a ?xible clock select scheme allows a total of four different clock sources to be used with the counters. each of the modulators can create independent continuous waveforms with software-selectable duty rates from 0% to 100%. the pwm outputs can be programmed as left aligned outputs or center aligned outputs 12.1.1 features four independent pwm channels with programmable period and duty cycle dedicated counter for each pwm channel programmable pwm enable/disable for each channel software selection of pwm duty pulse polarity for each channel period and duty cycle are double buffered. change takes effect when the end of the effective period is reached (pwm counter reaches 0) or when the channel is disabled. programmable center or left aligned outputs on individual channels four 8-bit channel or two16-bit channel pwm resolution four clock sources (a, b, sa, and sb) provide for a wide range of frequencies. programmable clock select logic emergency shutdown 12.1.2 modes of operation there is a software programmable option for low power consumption in wait mode that disables the input clock to the prescaler. in freeze mode there is a software programmable option to disable the input clock to the prescaler. this is useful for emulation.
chapter 12 pulse-width modulator (pwm8b4c) block description 348 mc9s12q128 freescale semiconductor rev 1.09 12.1.3 block diagram figure 12-1. pwm8b4c block diagram 12.2 external signal description the pwm8b4c module has a total of four external pins. 12.2.1 pwm3 ?pulse width modulator channel 3 pin this pin serves as waveform output of pwm channel 3. 12.2.2 pwm2 ?pulse width modulator channel 2 pin this pin serves as waveform output of pwm channel 2. 12.2.3 pwm1 ?pulse width modulator channel 1 pin this pin serves as waveform output of pwm channel 1. bus clock clock select pwm clock period and duty counter channel 3 period and duty counter channel 2 period and duty counter channel 1 period and duty counter channel 0 pwm channels alignment polarity control pwm8b4c pwm3 pwm2 pwm1 pwm0 enable
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 349 rev 1.09 12.2.4 pwm0 ?pulse width modulator channel 0 pin this pin serves as waveform output of pwm channel 0. 12.3 memory map and registers this subsection describes in detail all the registers and register bits in the pwm8b4c module. the special-purpose registers and register bit functions that would not normally be made available to device end users, such as factory test control registers and reserved registers are clearly identi?d by means of shading the appropriate portions of address maps and register diagrams. notes explaining the reasons for restricting access to the registers and functions are also explained in the individual register descriptions. 12.3.1 module memory map the following paragraphs describe the content of the registers in the pwm8b4c module. the base address of the pwm8b4c module is determined at the mcu level when the mcu is de?ed. the register decode map is ?ed and begins at the ?st address of the module address offset. reserved bits within a register will always read as 0 and the write will be unimplemented. unimplemented functions are indicated by shading the bit. table 12-2 shows the memory map for the pwm8b4c module. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level.
chapter 12 pulse-width modulator (pwm8b4c) block description 350 mc9s12q128 freescale semiconductor rev 1.09 12.3.2 register descriptions the following paragraphs describe in detail all the registers and register bits in the pwm8b4c module. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 pwme r0 0 pwme3 pwme2 pwme1 pwme0 w 0x0001 pwmpol r0 0 ppol3 ppol2 ppol1 ppol0 w 0x0002 pwmclk r0 0 pclk3 pclk2 pclk1 pclk0 w 0x0003 pwmprclk r0 pckb2 pckb1 pckb0 0 pcka2 pcka1 pcka0 w 0x0004 pwmcae r0 0 cae2 cae2 cae1 cae0 w 0x0005 pwmctl r0 con23 con01 pswai pfrz 00 w 0x0006 pwmtst r00000000 w 0x0007 pwmprsc r00000000 w 0x0008 pwmscla r bit 7 6 5 4 3 2 1 bit 0 w 0x0009 pwmsclb r bit 7 6 5 4 3 2 1 bit 0 w 0x000a pwmscnta r00000000 w 0x000b pwmscntb r00000000 w 0x000c pwmcnt0 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x000d pwmcnt1 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x000e pwmcnt2 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x000f pwmcnt3 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x0010 reserved r w 0x0011 reserved r w 0x0012 pwmper0 r bit 7 6 5 4 3 2 1 bit 0 w = unimplemented or reserved figure 12-2. pwm register summary
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 351 rev 1.09 12.3.2.1 pwm enable register (pwme) each pwm channel has an enable bit (pwmex) to start its waveform output. when any of the pwmex bits are set (pwmex = 1), the associated pwm output is enabled immediately. however, the actual pwm waveform is not available on the associated pwm output until its clock source begins its next cycle due to the synchronization of pwmex and the clock source. note the ?st pwm cycle after enabling the channel can be irregular. an exception to this is when channels are concatenated. after concatenated mode is enabled (conxx bits set in pwmctl register), enabling/disabling the corresponding 16-bit pwm channel is controlled by the low-order pwmex bit. in this case, the high-order bytes pwmex bits have no effect and their corresponding pwm output lines are disabled. while in run mode, if all pwm channels are disabled (pwme3?wme0 = 0), the prescaler counter shuts off for power savings. 0x0013 pwmper1 r bit 7 6 5 4 3 2 1 bit 0 w 0x0014 pwmper2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0015 pwmper3 r bit 7 6 5 4 3 2 1 bit 0 w 0x0016 reserved r w 0x0017 reserved r w 0x0018 pwmdty0 r bit 7 6 5 4 3 2 1 bit 0 w 0x0019 pwmper1 r bit 7 6 5 4 3 2 1 bit 0 w 0x001a pwmper2 r bit 7 6 5 4 3 2 1 bit 0 w 0x001b pwmper3 r bit 7 6 5 4 3 2 1 bit 0 w 0x001c reserved r w 0x001d reserved r w 0x001e pwmsdb r pwmif pwmie 0 pwmlvl 0 pwm5in pwm5inl pwm5ena w pwmrstrt address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 12-2. pwm register summary (continued)
chapter 12 pulse-width modulator (pwm8b4c) block description 352 mc9s12q128 freescale semiconductor rev 1.09 read: anytime write: anytime module base + 0x0000 76543210 r0 0 pwme3 pwme2 pwme1 pwme0 w reset 0 0 0 00000 = unimplemented or reserved figure 12-3. pwm enable register (pwme) table 12-1. pwme field descriptions field description 3 pwme3 pulse width channel 3 enable 0 pulse width channel 3 is disabled. 1 pulse width channel 3 is enabled. the pulse modulated signal becomes available at pwm, output bit 3 when its clock source begins its next cycle. 2 pwme2 pulse width channel 2 enable 0 pulse width channel 2 is disabled. 1 pulse width channel 2 is enabled. the pulse modulated signal becomes available at pwm, output bit 2 when its clock source begins its next cycle. if con23 = 1, then bit has no effect and pwm output line 2 is disabled. 1 pwme1 pulse width channel 1 enable 0 pulse width channel 1 is disabled. 1 pulse width channel 1 is enabled. the pulse modulated signal becomes available at pwm, output bit 1 when its clock source begins its next cycle. 0 pwme0 pulse width channel 0 enable 0 pulse width channel 0 is disabled. 1 pulse width channel 0 is enabled. the pulse modulated signal becomes available at pwm, output bit 0 when its clock source begins its next cycle. if con01 = 1, then bit has no effect and pwm output line 0 is disabled.
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 353 rev 1.09 12.3.2.2 pwm polarity register (pwmpol) the starting polarity of each pwm channel waveform is determined by the associated ppolx bit in the pwmpol register. if the polarity bit is 1, the pwm channel output is high at the beginning of the cycle and then goes low when the duty count is reached. conversely, if the polarity bit is 0 the output starts low and then goes high when the duty count is reached. read: anytime write: anytime note ppolx register bits can be written anytime. if the polarity is changed while a pwm signal is being generated, a truncated or stretched pulse can occur during the transition module base + 0x0001 76543210 r0 0 ppol3 ppol2 ppol1 ppol0 w reset 0 0 0 00000 = unimplemented or reserved figure 12-4. pwm polarity register (pwmpol) table 12-2. pwmpol field descriptions field description 3 ppol3 pulse width channel 3 polarity 0 pwm channel 3 output is low at the beginning of the period, then goes high when the duty count is reached. 1 pwm channel 3 output is high at the beginning of the period, then goes low when the duty count is reached. 2 ppol2 pulse width channel 2 polarity 0 pwm channel 2 output is low at the beginning of the period, then goes high when the duty count is reached. 1 pwm channel 2 output is high at the beginning of the period, then goes low when the duty count is reached. 1 ppol1 pulse width channel 1 polarity 0 pwm channel 1 output is low at the beginning of the period, then goes high when the duty count is reached. 1 pwm channel 1 output is high at the beginning of the period, then goes low when the duty count is reached. 0 ppol0 pulse width channel 0 polarity 0 pwm channel 0 output is low at the beginning of the period, then goes high when the duty count is reached 1 pwm channel 0 output is high at the beginning of the period, then goes low when the duty count is reached.
chapter 12 pulse-width modulator (pwm8b4c) block description 354 mc9s12q128 freescale semiconductor rev 1.09 12.3.2.3 pwm clock select register (pwmclk) each pwm channel has a choice of two clocks to use as the clock source for that channel as described below. read: anytime write: anytime note register bits pclk0 to pclk3 can be written anytime. if a clock select is changed while a pwm signal is being generated, a truncated or stretched pulse can occur during the transition. module base + 0x0002 76543210 r0 0 pclk3 pclk2 pclk1 pclk0 w reset 0 0 0 00000 = unimplemented or reserved figure 12-5. pwm clock select register (pwmclk) table 12-3. pwmclk field descriptions field description 3 pclk3 pulse width channel 3 clock select 0 clock b is the clock source for pwm channel 3. 1 clock sb is the clock source for pwm channel 3. 2 pclk2 pulse width channel 2 clock select 0 clock b is the clock source for pwm channel 2. 1 clock sb is the clock source for pwm channel 2. 1 pclk1 pulse width channel 1 clock select 0 clock a is the clock source for pwm channel 1. 1 clock sa is the clock source for pwm channel 1. 0 pclk0 pulse width channel 0 clock select 0 clock a is the clock source for pwm channel 0. 1 clock sa is the clock source for pwm channel 0.
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 355 rev 1.09 12.3.2.4 pwm prescale clock select register (pwmprclk) this register selects the prescale clock source for clocks a and b independently. read: anytime write: anytime note pckb2?ckb0 and pcka2?cka0 register bits can be written anytime. if the clock prescale is changed while a pwm signal is being generated, a truncated or stretched pulse can occur during the transition. module base + 0x0003 76543210 r0 pckb2 pckb1 pckb0 0 pcka2 pcka1 pcka0 w reset 0 0 0 00000 = unimplemented or reserved figure 12-6. pwm prescaler clock select register (pwmprclk) table 12-4. pwmprclk field descriptions field description 6? pckb[2:0] prescaler select for clock b clock b is 1 of two clock sources which can be used for channels 2 or 3. these three bits determine the rate of clock b, as shown in table 12-5 . 2? pcka[2:0] prescaler select for clock a clock a is 1 of two clock sources which can be used for channels 0, 1, 4, or 5. these three bits determine the rate of clock a, as shown in table 12-6 . table 12-5. clock b prescaler selects pckb2 pckb1 pckb0 value of clock b 0 0 0 bus clock 0 0 1 bus clock / 2 0 1 0 bus clock / 4 0 1 1 bus clock / 8 1 0 0 bus clock / 16 1 0 1 bus clock / 32 1 1 0 bus clock / 64 1 1 1 bus clock / 128
chapter 12 pulse-width modulator (pwm8b4c) block description 356 mc9s12q128 freescale semiconductor rev 1.09 12.3.2.5 pwm center align enable register (pwmcae) the pwmcae register contains control bits for the selection of center aligned outputs or left aligned outputs for each pwm channel. if the caex bit is set to a 1, the corresponding pwm output will be center aligned. if the caex bit is cleared, the corresponding pwm output will be left aligned. reference section 12.4.2.5, ?eft aligned outputs , and section 12.4.2.6, ?enter aligned outputs , for a more detailed description of the pwm output modes. read: anytime write: anytime note write these bits only when the corresponding channel is disabled. table 12-6. clock a prescaler selects pcka2 pcka1 pcka0 value of clock a 0 0 0 bus clock 0 0 1 bus clock / 2 0 1 0 bus clock / 4 0 1 1 bus clock / 8 1 0 0 bus clock / 16 1 0 1 bus clock / 32 1 1 0 bus clock / 64 1 1 1 bus clock / 128 module base + 0x0004 76543210 r0 0 cae3 cae2 cae1 cae0 w reset 0 0 0 00000 = unimplemented or reserved figure 12-7. pwm center align enable register (pwmcae) table 12-7. pwmcae field descriptions field description 3 cae3 center aligned output mode on channel 3 1 channel 3 operates in left aligned output mode. 1 channel 3 operates in center aligned output mode. 2 cae2 center aligned output mode on channel 2 0 channel 2 operates in left aligned output mode. 1 channel 2 operates in center aligned output mode.
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 357 rev 1.09 12.3.2.6 pwm control register (pwmctl) the pwmctl register provides for various control of the pwm module. read: anytime write: anytime there are control bits for concatenation, each of which is used to concatenate a pair of pwm channels into one 16-bit channel. when channels 2 and 3 are concatenated, channel 2 registers become the high-order bytes of the double-byte channel. when channels 0 and 1 are concatenated, channel 0 registers become the high-order bytes of the double-byte channel. reference section 12.4.2.7, ?wm 16-bit functions , for a more detailed description of the concatenation pwm function. note change these bits only when both corresponding channels are disabled. 1 cae1 center aligned output mode on channel 1 0 channel 1 operates in left aligned output mode. 1 channel 1 operates in center aligned output mode. 0 cae0 center aligned output mode on channel 0 0 channel 0 operates in left aligned output mode. 1 channel 0 operates in center aligned output mode. module base + 0x0005 76543210 r0 con23 con01 pswai pfrz 00 w reset 0 0 0 00000 = unimplemented or reserved figure 12-8. pwm control register (pwmctl) table 12-7. pwmcae field descriptions (continued) field description
chapter 12 pulse-width modulator (pwm8b4c) block description 358 mc9s12q128 freescale semiconductor rev 1.09 table 12-8. pwmctl field descriptions field description 5 con23 concatenate channels 2 and 3 0 channels 2 and 3 are separate 8-bit pwms. 1 channels 2 and 3 are concatenated to create one 16-bit pwm channel. channel 2 becomes the high-order byte and channel 3 becomes the low-order byte. channel 3 output pin is used as the output for this 16-bit pwm (bit 3 of port pwmp). channel 3 clock select control bit determines the clock source, channel 3 polarity bit determines the polarity, channel 3 enable bit enables the output and channel 3 center aligned enable bit determines the output mode. 4 con01 concatenate channels 0 and 1 0 channels 0 and 1 are separate 8-bit pwms. 1 channels 0 and 1 are concatenated to create one 16-bit pwm channel. channel 0 becomes the high-order byte and channel 1 becomes the low-order byte. channel 1 output pin is used as the output for this 16-bit pwm (bit 1 of port pwmp). channel 1 clock select control bit determines the clock source, channel 1 polarity bit determines the polarity, channel 1 enable bit enables the output and channel 1 center aligned enable bit determines the output mode. 3 pswai pwm stops in wait mode enabling this bit allows for lower power consumption in wait mode by disabling the input clock to the prescaler. 0 allow the clock to the prescaler to continue while in wait mode. 1 stop the input clock to the prescaler whenever the mcu is in wait mode. 2 pfrz pwm counters stop in freeze mode ?in freeze mode, there is an option to disable the input clock to the prescaler by setting the pfrz bit in the pwmctl register. if this bit is set, whenever the mcu is in freeze mode the input clock to the prescaler is disabled. this feature is useful during emulation as it allows the pwm function to be suspended. in this way, the counters of the pwm can be stopped while in freeze mode so that after normal program ?w is continued, the counters are re-enabled to simulate real-time operations. because the registers remain accessible in this mode, to re-enable the prescaler clock, either disable the pfrz bit or exit freeze mode. 0 allow pwm to continue while in freeze mode. 1 disable pwm input clock to the prescaler whenever the part is in freeze mode. this is useful for emulation.
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 359 rev 1.09 12.3.2.7 reserved register (pwmtst) this register is reserved for factory testing of the pwm module and is not available in normal modes. read: always read 0x0000 in normal modes write: unimplemented in normal modes note writing to this register when in special modes can alter the pwm functionality. 12.3.2.8 reserved register (pwmprsc) this register is reserved for factory testing of the pwm module and is not available in normal modes. read: always read 0x0000 in normal modes write: unimplemented in normal modes note writing to this register when in special modes can alter the pwm functionality. module base + 0x0006 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 12-9. reserved register (pwmtst) module base + 0x0007 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 12-10. reserved register (pwmprsc)
chapter 12 pulse-width modulator (pwm8b4c) block description 360 mc9s12q128 freescale semiconductor rev 1.09 12.3.2.9 pwm scale a register (pwmscla) pwmscla is the programmable scale value used in scaling clock a to generate clock sa. clock sa is generated by taking clock a, dividing it by the value in the pwmscla register and dividing that by two. clock sa = clock a / (2 * pwmscla) note when pwmscla = 0x0000, pwmscla value is considered a full scale value of 256. clock a is thus divided by 512. any value written to this register will cause the scale counter to load the new scale value (pwmscla). read: anytime write: anytime (causes the scale counter to load the pwmscla value) 12.3.2.10 pwm scale b register (pwmsclb) pwmsclb is the programmable scale value used in scaling clock b to generate clock sb. clock sb is generated by taking clock b, dividing it by the value in the pwmsclb register and dividing that by two. clock sb = clock b / (2 * pwmsclb) note when pwmsclb = 0x0000, pwmsclb value is considered a full scale value of 256. clock b is thus divided by 512. any value written to this register will cause the scale counter to load the new scale value (pwmsclb). read: anytime write: anytime (causes the scale counter to load the pwmsclb value). module base + 0x0008 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 0 0 0 00000 figure 12-11. pwm scale a register (pwmscla) module base + 0x0009 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 0 0 0 00000 figure 12-12. pwm scale b register (pwmsclb)
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 361 rev 1.09 12.3.2.11 reserved registers (pwmscntx) the registers pwmscnta and pwmscntb are reserved for factory testing of the pwm module and are not available in normal modes. read: always read 0x0000 in normal modes write: unimplemented in normal modes note writing to these registers when in special modes can alter the pwm functionality. 12.3.2.12 pwm channel counter registers (pwmcntx) each channel has a dedicated 8-bit up/down counter which runs at the rate of the selected clock source. the counter can be read at any time without affecting the count or the operation of the pwm channel. in left aligned output mode, the counter counts from 0 to the value in the period register 1. in center aligned output mode, the counter counts from 0 up to the value in the period register and then back down to 0. any value written to the counter causes the counter to reset to 0x0000, the counter direction to be set to up, the immediate load of both duty and period registers with values from the buffers, and the output to change according to the polarity bit. the counter is also cleared at the end of the effective period (see section 12.4.2.5, ?eft aligned outputs , and section 12.4.2.6, ?enter aligned outputs , for more details). when the channel is disabled (pwmex = 0), the pwmcntx register does not count. when a channel becomes enabled (pwmex = 1), the associated pwm counter starts at the count in the pwmcntx register. for more detailed information on the operation of the counters, reference section 12.4.2.4, ?wm timer counters. module base + 0x000a 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 12-13. reserved register (pwmscnta) module base + 0x000b 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 12-14. reserved register (pwmscntb)
chapter 12 pulse-width modulator (pwm8b4c) block description 362 mc9s12q128 freescale semiconductor rev 1.09 in concatenated mode, writes to the 16-bit counter by using a 16-bit access or writes to either the low- or high-order byte of the counter will reset the 16-bit counter. reads of the 16-bit counter must be made by 16-bit access to maintain data coherency. note writing to the counter while the channel is enabled can cause an irregular pwm cycle to occur. read: anytime write: anytime (any value written causes pwm counter to be reset to 0x0000). module base + 0x000c 76543210 r bit 7 6 5 4321 bit 0 w00000000 reset 0 0 0 00000 figure 12-15. pwm channel counter registers (pwmcnt0) module base + 0x000d 76543210 r bit 7 6 5 4321 bit 0 w00000000 reset 0 0 0 00000 figure 12-16. pwm channel counter registers (pwmcnt1) module base + 0x000e 76543210 r bit 7 6 5 4321 bit 0 w00000000 reset 0 0 0 00000 figure 12-17. pwm channel counter registers (pwmcnt2) module base + 0x000f 76543210 r bit 7 6 5 4321 bit 0 w00000000 reset 0 0 0 00000 figure 12-18. pwm channel counter registers (pwmcnt3)
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 363 rev 1.09 12.3.2.13 pwm channel period registers (pwmperx) there is a dedicated period register for each channel. the value in this register determines the period of the associated pwm channel. the period registers for each channel are double buffered so that if they change while the channel is enabled, the change will not take effect until one of the following occurs: the effective period ends the counter is written (counter resets to 0x0000) the channel is disabled in this way, the output of the pwm will always be either the old waveform or the new waveform, not some variation in between. if the channel is not enabled, then writes to the period register will go directly to the latches as well as the buffer. note reads of this register return the most recent value written. reads do not necessarily return the value of the currently active period due to the double buffering scheme. reference section 12.4.2.3, ?wm period and duty , for more information. to calculate the output period, take the selected clock source period for the channel of interest (a, b, sa, or sb) and multiply it by the value in the period register for that channel: left aligned output (caex = 0) pwmx period = channel clock period * pwmperx center aligned output (caex = 1) pwmx period = channel clock period * (2 * pwmperx) for boundary case programming values, please refer to section 12.4.2.8, ?wm boundary cases. module base + 0x0012 76543210 r bit 7 6 5 4321 bit 0 w reset 0 0 0 00000 figure 12-19. pwm channel period registers (pwmper0) module base + 0x0013 76543210 r bit 7 6 5 4321 bit 0 w reset 0 0 0 00000 figure 12-20. pwm channel period registers (pwmper1)
chapter 12 pulse-width modulator (pwm8b4c) block description 364 mc9s12q128 freescale semiconductor rev 1.09 read: anytime write: anytime 12.3.2.14 pwm channel duty registers (pwmdtyx) there is a dedicated duty register for each channel. the value in this register determines the duty of the associated pwm channel. the duty value is compared to the counter and if it is equal to the counter value a match occurs and the output changes state. the duty registers for each channel are double buffered so that if they change while the channel is enabled, the change will not take effect until one of the following occurs: the effective period ends the counter is written (counter resets to 0x0000) the channel is disabled in this way, the output of the pwm will always be either the old duty waveform or the new duty waveform, not some variation in between. if the channel is not enabled, then writes to the duty register will go directly to the latches as well as the buffer. note reads of this register return the most recent value written. reads do not necessarily return the value of the currently active duty due to the double buffering scheme. reference section 12.4.2.3, ?wm period and duty , for more information. module base + 0x0014 76543210 r bit 7 6 5 4321 bit 0 w reset 0 0 0 00000 figure 12-21. pwm channel period registers (pwmper2) module base + 0x0015 76543210 r bit 7 6 5 4321 bit 0 w reset 0 0 0 00000 figure 12-22. pwm channel period registers (pwmper3)
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 365 rev 1.09 note depending on the polarity bit, the duty registers will contain the count of either the high time or the low time. if the polarity bit is 1, the output starts high and then goes low when the duty count is reached, so the duty registers contain a count of the high time. if the polarity bit is 0, the output starts low and then goes high when the duty count is reached, so the duty registers contain a count of the low time. to calculate the output duty cycle (high time as a % of period) for a particular channel: polarity = 0 (ppolx = 0) duty cycle = [(pwmperx?wmdtyx)/pwmperx] * 100% polarity = 1 (ppolx = 1) duty cycle = [pwmdtyx / pwmperx] * 100% for boundary case programming values, please refer to section 12.4.2.8, ?wm boundary cases. read: anytime write: anytime module base + 0x0018 76543210 r bit 7 6 5 4321 bit 0 w reset 1 1 1 11111 figure 12-23. pwm channel duty registers (pwmdty0) module base + 0x0019 76543210 r bit 7 6 5 4321 bit 0 w reset 1 1 1 11111 figure 12-24. pwm channel duty registers (pwmdty1) module base + 0x001a 76543210 r bit 7 6 5 4321 bit 0 w reset 1 1 1 11111 figure 12-25. pwm channel duty registers (pwmdty2) module base + 0x001b 76543210 r bit 7 6 5 4321 bit 0 w reset 1 1 1 11111 figure 12-26. pwm channel duty registers (pwmdty3)
chapter 12 pulse-width modulator (pwm8b4c) block description 366 mc9s12q128 freescale semiconductor rev 1.09 12.3.2.15 pwm shutdown register (pwmsdn) the pwmsdn register provides for the shutdown functionality of the pwm module in the emergency cases. read: anytime write: anytime module base + 0x00e 76543210 r 0 pwm5ena w reset 0 0 0 00000 = unimplemented or reserved figure 12-27. pwm shutdown register (pwmsdn) table 12-9. pwmsdn field descriptions field description 0 pwm5ena pwm emergency shutdown enable 0 pwm emergency feature disabled. 1 pwm emergency feature is enabled. caution user software must ensure that this bit remains clear
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 367 rev 1.09 12.4 functional description 12.4.1 pwm clock select there are four available clocks called clock a, clock b, clock sa (scaled a), and clock sb (scaled b). these four clocks are based on the bus clock . clock a and b can be software selected to be 1, 1/2, 1/4, 1/8,..., 1/64, 1/128 times the bus clock. clock sa uses clock a as an input and divides it further with a reloadable counter. similarly, clock sb uses clock b as an input and divides it further with a reloadable counter. the rates available for clock sa are software selectable to be clock a divided by 2, 4, 6, 8, ..., or 512 in increments of divide by 2. similar rates are available for clock sb. each pwm channel has the capability of selecting one of two clocks, either the pre-scaled clock (clock a or b) or the scaled clock (clock sa or sb). the block diagram in figure 12-28 shows the four different clocks and how the scaled clocks are created. 12.4.1.1 prescale the input clock to the pwm prescaler is the bus clock. it can be disabled whenever the part is in freeze mode by setting the pfrz bit in the pwmctl register. if this bit is set, whenever the mcu is in freeze mode the input clock to the prescaler is disabled. this is useful for emulation in order to freeze the pwm. the input clock can also be disabled when all six pwm channels are disabled (pwme5?wme0 = 0) this is useful for reducing power by disabling the prescale counter. clock a and clock b are scaled values of the input clock. the value is software selectable for both clock a and clock b and has options of 1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, or 1/128 times the bus clock. the value selected for clock a is determined by the pcka2, pcka1, and pcka0 bits in the pwmprclk register. the value selected for clock b is determined by the pckb2, pckb1, and pckb0 bits also in the pwmprclk register.
chapter 12 pulse-width modulator (pwm8b4c) block description 368 mc9s12q128 freescale semiconductor rev 1.09 figure 12-28. pwm clock select block diagram 2 4 8 16 32 64 128 pckb2 pckb1 pckb0 m u x clock a clock b clock sa clock a/2, a/4, a/6,....a/512 prescale scale divide by prescaler taps: pfrz freeze bus clock clock select m u x pclk0 clock to pwm ch 0 m u x pclk2 clock to pwm ch 2 m u x pclk1 clock to pwm ch 1 m u x pclk3 clock to pwm ch 3 load div 2 pwmsclb 8-bit down counter clock sb clock b/2, b/4, b/6,....b/512 m u x pcka2 pcka1 pcka0 pwme5:0 count = 1 load div 2 pwmscla 8-bit down counter count = 1
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 369 rev 1.09 12.4.1.2 clock scale the scaled a clock uses clock a as an input and divides it further with a user programmable value and then divides this by 2. the scaled b clock uses clock b as an input and divides it further with a user programmable value and then divides this by 2. the rates available for clock sa are software selectable to be clock a divided by 2, 4, 6, 8, ..., or 512 in increments of divide by 2. similar rates are available for clock sb. clock a is used as an input to an 8-bit down counter. this down counter loads a user programmable scale value from the scale register (pwmscla). when the down counter reaches 1, two things happen; a pulse is output and the 8-bit counter is re-loaded. the output signal from this circuit is further divided by two. this gives a greater range with only a slight reduction in granularity. clock sa equals clock a divided by two times the value in the pwmscla register. note clock sa = clock a / (2 * pwmscla) when pwmscla = 0x0000, pwmscla value is considered a full scale value of 256. clock a is thus divided by 512. similarly, clock b is used as an input to an 8-bit down counter followed by a divide by two producing clock sb. thus, clock sb equals clock b divided by two times the value in the pwmsclb register. note clock sb = clock b / (2 * pwmsclb) when pwmsclb = 0x0000, pwmsclb value is considered a full scale value of 256. clock b is thus divided by 512. as an example, consider the case in which the user writes 0x00ff into the pwmscla register. clock a for this case will be bus clock divided by 4. a pulse will occur at a rate of once every 255 x 4 bus cycles. passing this through the divide by two circuit produces a clock signal at a bus clock divided by 2040 rate. similarly, a value of 0x0001 in the pwmscla register when clock a is bus clock divided by 4 will produce a bus clock divided by 8 rate. writing to pwmscla or pwmsclb causes the associated 8-bit down counter to be re-loaded. otherwise, when changing rates the counter would have to count down to 0x0001 before counting at the proper rate. forcing the associated counter to re-load the scale register value every time pwmscla or pwmsclb is written prevents this. note writing to the scale registers while channels are operating can cause irregularities in the pwm outputs.
chapter 12 pulse-width modulator (pwm8b4c) block description 370 mc9s12q128 freescale semiconductor rev 1.09 12.4.1.3 clock select each pwm channel has the capability of selecting one of two clocks. for channels 0, and 1 the clock choices are clock a or clock sa. for channels 2 and 3 the choices are clock b or clock sb. the clock selection is done with the pclkx control bits in the pwmclk register. note changing clock control bits while channels are operating can cause irregularities in the pwm outputs. 12.4.2 pwm channel timers the main part of the pwm module are the actual timers. each of the timer channels has a counter, a period register and a duty register (each are 8 bit). the waveform output period is controlled by a match between the period register and the value in the counter. the duty is controlled by a match between the duty register and the counter value and causes the state of the output to change during the period. the starting polarity of the output is also selectable on a per channel basis. figure 12-29 shows a block diagram for pwm timer. figure 12-29. pwm timer channel block diagram clock source t r q q m u x ppolx from port pwmp data register pwmex (clock edge sync) to pin driver gate 8-bit compare = pwmdtyx 8-bit compare = pwmperx m u x caex up/down t r q q reset 8-bit counter pwmcntx
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 371 rev 1.09 12.4.2.1 pwm enable each pwm channel has an enable bit (pwmex) to start its waveform output. when any of the pwmex bits are set (pwmex = 1), the associated pwm output signal is enabled immediately. however, the actual pwm waveform is not available on the associated pwm output until its clock source begins its next cycle due to the synchronization of pwmex and the clock source. an exception to this is when channels are concatenated. refer to section 12.4.2.7, ?wm 16-bit functions , for more detail. note the ?st pwm cycle after enabling the channel can be irregular. on the front end of the pwm timer, the clock is enabled to the pwm circuit by the pwmex bit being high. there is an edge-synchronizing circuit to guarantee that the clock will only be enabled or disabled at an edge. when the channel is disabled (pwmex = 0), the counter for the channel does not count. 12.4.2.2 pwm polarity each channel has a polarity bit to allow starting a waveform cycle with a high or low signal. this is shown on the block diagram as a mux select of either the q output or the q output of the pwm output flip-flop. when one of the bits in the pwmpol register is set, the associated pwm channel output is high at the beginning of the waveform, then goes low when the duty count is reached. conversely, if the polarity bit is 0, the output starts low and then goes high when the duty count is reached. 12.4.2.3 pwm period and duty dedicated period and duty registers exist for each channel and are double buffered so that if they change while the channel is enabled, the change will not take effect until one of the following occurs: the effective period ends the counter is written (counter resets to 0x0000) the channel is disabled in this way, the output of the pwm will always be either the old waveform or the new waveform, not some variation in between. if the channel is not enabled, then writes to the period and duty registers will go directly to the latches as well as the buffer. a change in duty or period can be forced into effect ?mmediately?by writing the new value to the duty and/or period registers and then writing to the counter. this forces the counter to reset and the new duty and/or period values to be latched. in addition, because the counter is readable it is possible to know where the count is with respect to the duty value and software can be used to make adjustments . note when forcing a new period or duty into effect immediately, an irregular pwm cycle can occur. depending on the polarity bit, the duty registers will contain the count of either the high time or the low time.
chapter 12 pulse-width modulator (pwm8b4c) block description 372 mc9s12q128 freescale semiconductor rev 1.09 12.4.2.4 pwm timer counters each channel has a dedicated 8-bit up/down counter which runs at the rate of the selected clock source (reference figure 12-28 for the available clock sources and rates). the counter compares to two registers, a duty register and a period register as shown in figure 12-29 . when the pwm counter matches the duty register the output flip-flop changes state causing the pwm waveform to also change state. a match between the pwm counter and the period register behaves differently depending on what output mode is selected as shown in figure 12-29 and described in section 12.4.2.5, ?eft aligned outputs , and section 12.4.2.6, ?enter aligned outputs. each channel counter can be read at anytime without affecting the count or the operation of the pwm channel. any value written to the counter causes the counter to reset to 0x0000, the counter direction to be set to up, the immediate load of both duty and period registers with values from the buffers, and the output to change according to the polarity bit. when the channel is disabled (pwmex = 0), the counter stops. when a channel becomes enabled (pwmex = 1), the associated pwm counter continues from the count in the pwmcntx register. this allows the waveform to resume when the channel is re-enabled. when the channel is disabled, writing 0 to the period register will cause the counter to reset on the next selected clock. note if the user wants to start a new ?lean?pwm waveform without any ?istory?from the old waveform, the user must write to channel counter (pwmcntx) prior to enabling the pwm channel (pwmex = 1). generally, writes to the counter are done prior to enabling a channel to start from a known state. however, writing a counter can also be done while the pwm channel is enabled (counting). the effect is similar to writing the counter when the channel is disabled except that the new period is started immediately with the output set according to the polarity bit. note writing to the counter while the channel is enabled can cause an irregular pwm cycle to occur. the counter is cleared at the end of the effective period (see section 12.4.2.5, ?eft aligned outputs , and section 12.4.2.6, ?enter aligned outputs , for more details). table 12-10. pwm timer counter conditions counter clears (0x0000) counter counts counter stops when pwmcntx register written to any value when pwm channel is enabled (pwmex = 1). counts from last value in pwmcntx. when pwm channel is disabled (pwmex = 0) effective period ends
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 373 rev 1.09 12.4.2.5 left aligned outputs the pwm timer provides the choice of two types of outputs, left aligned or center aligned outputs. they are selected with the caex bits in the pwmcae register. if the caex bit is cleared (caex = 0), the corresponding pwm output will be left aligned. in left aligned output mode, the 8-bit counter is configured as an up counter only. it compares to two registers, a duty register and a period register as shown in the block diagram in figure 12-29 . when the pwm counter matches the duty register the output flip-flop changes state causing the pwm waveform to also change state. a match between the pwm counter and the period register resets the counter and the output flip-flop as shown in figure 12-29 as well as performing a load from the double buffer period and duty register to the associated registers as described in section 12.4.2.3, ?wm period and duty. the counter counts from 0 to the value in the period register ?1. note changing the pwm output mode from left aligned output to center aligned output (or vice versa) while channels are operating can cause irregularities in the pwm output. it is recommended to program the output mode before enabling the pwm channel. figure 12-30. pwm left aligned output waveform to calculate the output frequency in left aligned output mode for a particular channel, take the selected clock source frequency for the channel (a, b, sa, or sb) and divide it by the value in the period register for that channel. pwmx frequency = clock (a, b, sa, or sb) / pwmperx pwmx duty cycle (high time as a% of period): polarity = 0 (ppolx = 0) duty cycle = [(pwmperx-pwmdtyx)/pwmperx] * 100% polarity = 1 (ppolx = 1) duty cycle = [pwmdtyx / pwmperx] * 100% as an example of a left aligned output, consider the following case: clock source = bus clock, where bus clock = 10 mhz (100 ns period) ppolx = 0 pwmperx = 4 pwmdtyx = 1 pwmx frequency = 10 mhz/4 = 2.5 mhz pwmx period = 400 ns pwmx duty cycle = 3/4 *100% = 75% pwmdtyx period = pwmperx ppolx = 0 ppolx = 1
chapter 12 pulse-width modulator (pwm8b4c) block description 374 mc9s12q128 freescale semiconductor rev 1.09 shown below is the output waveform generated. figure 12-31. pwm left aligned output example waveform 12.4.2.6 center aligned outputs for center aligned output mode selection, set the caex bit (caex = 1) in the pwmcae register and the corresponding pwm output will be center aligned. the 8-bit counter operates as an up/down counter in this mode and is set to up whenever the counter is equal to 0x0000. the counter compares to two registers, a duty register and a period register as shown in the block diagram in figure 12-29 . when the pwm counter matches the duty register the output flip-flop changes state causing the pwm waveform to also change state. a match between the pwm counter and the period register changes the counter direction from an up-count to a down-count. when the pwm counter decrements and matches the duty register again, the output flip-flop changes state causing the pwm output to also change state. when the pwm counter decrements and reaches 0, the counter direction changes from a down-count back to an up-count and a load from the double buffer period and duty registers to the associated registers is performed as described in section 12.4.2.3, ?wm period and duty. the counter counts from 0 up to the value in the period register and then back down to 0. thus the effective period is pwmperx*2. note changing the pwm output mode from left aligned output to center aligned output (or vice versa) while channels are operating can cause irregularities in the pwm output. it is recommended to program the output mode before enabling the pwm channel. figure 12-32. pwm center aligned output waveform e = 100 ns duty cycle = 75% period = 400 ns ppolx = 0 ppolx = 1 pwmdtyx pwmdtyx period = pwmperx*2 pwmperx pwmperx
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 375 rev 1.09 to calculate the output frequency in center aligned output mode for a particular channel, take the selected clock source frequency for the channel (a, b, sa, or sb) and divide it by twice the value in the period register for that channel. pwmx frequency = clock (a, b, sa, or sb) / (2*pwmperx) pwmx duty cycle (high time as a% of period): polarity = 0 (ppolx = 0) duty cycle = [(pwmperx-pwmdtyx)/pwmperx] * 100% polarity = 1 (ppolx = 1) duty cycle = [pwmdtyx / pwmperx] * 100% as an example of a center aligned output, consider the following case: clock source = bus clock, where bus clock = 10 mhz (100 ns period) ppolx = 0 pwmperx = 4 pwmdtyx = 1 pwmx frequency = 10 mhz/8 = 1.25 mhz pwmx period = 800 ns pwmx duty cycle = 3/4 *100% = 75% shown below is the output waveform generated. figure 12-33. pwm center aligned output example waveform 12.4.2.7 pwm 16-bit functions the pwm timer also has the option of generating 4-channels of 8-bits or 2-channels of 16-bits for greater pwm resolution}. this 16-bit channel option is achieved through the concatenation of two 8-bit channels. the pwmctl register contains three control bits, each of which is used to concatenate a pair of pwm channels into one 16-bit channel. channels 2 and 3 are concatenated with the con23 bit, and channels 0 and 1 are concatenated with the con01 bit. note change these bits only when both corresponding channels are disabled. when channels 2 and 3 are concatenated, channel 2 registers become the high-order bytes of the double byte channel. when channels 0 and 1 are concatenated, channel 0 registers become the high-order bytes of the double byte channel. e = 100 ns e = 100 ns period = 800 ns duty cycle = 75%
chapter 12 pulse-width modulator (pwm8b4c) block description 376 mc9s12q128 freescale semiconductor rev 1.09 figure 12-34. pwm 16-bit mode when using the 16-bit concatenated mode, the clock source is determined by the low-order 8-bit channel clock select control bits. that is channel 3 when channels 2 and 3 are concatenated, and channel 1 when channels 0 and 1 are concatenated. the resulting pwm is output to the pins of the corresponding low-order 8-bit channel as also shown in figure 12-34 . the polarity of the resulting pwm output is controlled by the ppolx bit of the corresponding low-order 8-bit channel as well. after concatenated mode is enabled (conxx bits set in pwmctl register), enabling/disabling the corresponding 16-bit pwm channel is controlled by the low-order pwmex bit. in this case, the high-order bytes pwmex bits have no effect and their corresponding pwm output is disabled. in concatenated mode, writes to the 16-bit counter by using a 16-bit access or writes to either the low or high-order byte of the counter will reset the 16-bit counter. reads of the 16-bit counter must be made by 16-bit access to maintain data coherency. either left aligned or center aligned output mode can be used in concatenated mode and is controlled by the low-order caex bit. the high-order caex bit has no effect. table 12-11 is used to summarize which channels are used to set the various control bits when in 16-bit mode. table 12-11. 16-bit concatenation mode summary conxx pwmex ppolx pclkx caex pwmx output con23 pwme3 ppol3 pclk3 cae3 pwm3 con01 pwme1 ppol1 pclk1 cae1 pwm1 pwmcnt2 pwcnt3 pwm3 clock source 3 high low period/duty compare pwmcnt0 pwcnt1 pwm1 clock source 1 high low period/duty compare
chapter 12 pulse-width modulator (pwm8b4c) block description freescale semiconductor mc9s12q128 377 rev 1.09 12.4.2.8 pwm boundary cases table 12-12 summarizes the boundary conditions for the pwm regardless of the output mode (left aligned or center aligned) and 8-bit (normal) or 16-bit (concatenation): 12.5 resets the reset state of each individual bit is listed within the register description section (see section 12.3, ?emory map and registers , which details the registers and their bit-?lds. all special functions or modes which are initialized during or just following reset are described within this section. the 8-bit up/down counter is con?ured as an up counter out of reset. all the channels are disabled and all the counters dont count. 12.6 interrupts the pwm8b4c module interrupt is disabled when pwm5ena is clear. caution user software must ensure that pwm5ena remains clear a description of the registers involved and affected due to this interrupt is explained in section 12.3.2.15, ?wm shutdown register (pwmsdn). table 12-12. pwm boundary cases pwmdtyx pwmperx ppolx pwmx output 0x0000 (indicates no duty) >0x0000 1 always low 0x0000 (indicates no duty) >0x0000 0 always high xx 0x0000 (1) (indicates no period) 1. counter = 0x0000 and does not count. 1 always high xx 0x0000 1 (indicates no period) 0 always low >= pwmperx xx 1 always high >= pwmperx xx 0 always low
chapter 12 pulse-width modulator (pwm8b4c) block description 378 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 379 rev 1.09 chapter 13 serial communications interface (s12sciv2) block description 13.1 introduction this block guide provide an overview of serial communication interface (sci) module. the sci allows asynchronous serial communications with peripheral devices and other cpus. 13.1.1 glossary irq ?interrupt request lsb ?least signi?ant bit msb ?most signi?ant bit nrz ?non-return-to-zero rzi ?return-to-zero-inverted rxd ?receive pin sci ?serial communication interface txd ?transmit pin 13.1.2 features the sci includes these distinctive features: full-duplex operation standard mark/space non-return-to-zero (nrz) format 13-bit baud rate selection programmable 8-bit or 9-bit data format separately enabled transmitter and receiver programmable transmitter output parity two receiver wake up methods: idle line wake-up address mark wake-up interrupt-driven operation with eight ?gs: transmitter empty
chapter 13 serial communications interface (s12sciv2) block description 380 mc9s12q128 freescale semiconductor rev 1.09 transmission complete receiver full idle receiver input receiver overrun noise error framing error parity error receiver framing error detection hardware parity checking 1/16 bit-time noise detection 13.1.3 modes of operation the sci operation is the same independent of device resource mapping and bus interface mode. different power modes are available to facilitate power saving. 13.1.3.1 run mode normal mode of operation. 13.1.3.2 wait mode sci operation in wait mode depends on the state of the sciswai bit in the sci control register 1 (scicr1). if sciswai is clear, the sci operates normally when the cpu is in wait mode. if sciswai is set, sci clock generation ceases and the sci module enters a power-conservation state when the cpu is in wait mode. setting sciswai does not affect the state of the receiver enable bit, re, or the transmitter enable bit, te. if sciswai is set, any transmission or reception in progress stops at wait mode entry. the transmission or reception resumes when either an internal or external interrupt brings the cpu out of wait mode. exiting wait mode by reset aborts any transmission or reception in progress and resets the sci. 13.1.3.3 stop mode the sci is inactive during stop mode for reduced power consumption. the stop instruction does not affect the sci register states, but the sci module clock will be disabled. the sci operation resumes from where it left off after an external interrupt brings the cpu out of stop mode. exiting stop mode by reset aborts any transmission or reception in progress and resets the sci.
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 381 rev 1.09 13.1.4 block diagram figure 13-1 is a high level block diagram of the sci module, showing the interaction of various functional blocks. figure 13-1. sci block diagram 13.2 external signal description the sci module has a total of two external pins: 13.2.1 txd-sci transmit pin this pin serves as transmit data output of sci. 13.2.2 rxd-sci receive pin this pin serves as receive data input of the sci. sci data register receive shift register receive & wake up control data format control transmit control transmit shift register sci data register baud generator rx data in 16 bus clock txdata out idle irq rdr/or irq tdre irq tc irq oring irq generation irq generation irq to cpu
chapter 13 serial communications interface (s12sciv2) block description 382 mc9s12q128 freescale semiconductor rev 1.09 13.3 memory map and registers this section provides a detailed description of all memory and registers. 13.3.1 module memory map the memory map for the sci module is given below in figure 13-2 . the address listed for each register is the address offset. the total address for each register is the sum of the base address for the sci module and the address offset for each register. 13.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. writes to a reserved register location do not have any effect and reads of these locations return a zero. details of register bit and ?ld function follow the register diagrams, in bit order. address name bit 7 65432 1 bit 0 0x0000 scibdh r0 0 0 sbr12 sbr11 sbr10 sbr9 sbr8 w 0x0001 scibdl r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w 0x0002 scicr1 r loops sciswai rsrc m wake ilt pe pt w 0x0003 scicr2 r tie tcie rie ilie te re rwu sbk w 0x0004 scisr1 r tdre tc rdrf idle or nf fe pf w 0x0005 scisr2 r0 0000 brk13 txdir raf w 0x0006 scidrh rr8 t8 0000 0 0 w 0x0007 scidrl rr7 r6r5r4r3r2 r1 r0 wt7 t6t5t4t3t2 t1 t0 = unimplemented or reserved figure 13-2. sci register summary
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 383 rev 1.09 13.3.2.1 sci baud rate registers (scibdh and schbdl) the sci baud rate register is used by the counter to determine the baud rate of the sci. the formula for calculating the baud rate is: sci baud rate = sci module clock / (16 x br) where: br is the content of the sci baud rate registers, bits sbr12 through sbr0. the baud rate registers can contain a value from 1 to 8191. read: anytime. if only scibdh is written to, a read will not return the correct data until scibdl is written to as well, following a write to scibdh. write: anytime module base + 0x_0000 76543210 r000 sbr12 sbr11 sbr10 sbr9 sbr8 w reset 0 0 0 00000 module base + 0x_0001 76543210 r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w reset 0 0 0 00100 = unimplemented or reserved figure 13-3. sci baud rate registers (scibdh and scibdl) table 13-1. scibdh and scibdl field descriptions field description 4? 7? sbr[12:0] sci baud rate bits ?the baud rate for the sci is determined by these 13 bits. note: the baud rate generator is disabled until the te bit or the re bit is set for the ?st time after reset. the baud rate generator is disabled when br = 0. writing to scibdh has no effect without writing to scibdl, since writing to scibdh puts the data in a temporary location until scibdl is written to.
chapter 13 serial communications interface (s12sciv2) block description 384 mc9s12q128 freescale semiconductor rev 1.09 13.3.2.2 sci control register 1 (scicr1) read: anytime write: anytime module base + 0x_0002 76543210 r loops sciswai rsrc m wake ilt pe pt w reset 0 0 0 00000 figure 13-4. sci control register 1 (scicr1) table 13-2. scicr1 field descriptions field description 7 loops loop select bit loops enables loop operation. in loop operation, the rxd pin is disconnected from the sci and the transmitter output is internally connected to the receiver input. both the transmitter and the receiver must be enabled to use the loop function.see table 13-3 . 0 normal operation enabled 1 loop operation enabled note: the receiver input is determined by the rsrc bit. 6 sciswai sci stop in wait mode bit ?sciswai disables the sci in wait mode. 0 sci enabled in wait mode 1 sci disabled in wait mode 5 rsrc receiver source bit ?when loops = 1, the rsrc bit determines the source for the receiver shift register input. 0 receiver input internally connected to transmitter output 1 receiver input connected externally to transmitter 4 m data format mode bit ?mode determines whether data characters are eight or nine bits long. 0 one start bit, eight data bits, one stop bit 1 one start bit, nine data bits, one stop bit 3 wake wakeup condition bit wake determines which condition wakes up the sci: a logic 1 (address mark) in the most signi?ant bit position of a received data character or an idle condition on the rxd. 0 idle line wakeup 1 address mark wakeup 2 ilt idle line type bit ?ilt determines when the receiver starts counting logic 1s as idle character bits. the counting begins either after the start bit or after the stop bit. if the count begins after the start bit, then a string of logic 1s preceding the stop bit may cause false recognition of an idle character. beginning the count after the stop bit avoids false idle character recognition, but requires properly synchronized transmissions. 0 idle character bit count begins after start bit 1 idle character bit count begins after stop bit 1 pe parity enable bit pe enables the parity function. when enabled, the parity function inserts a parity bit in the most signi?ant bit position. 0 parity function disabled 1 parity function enabled 0 pt parity type bit pt determines whether the sci generates and checks for even parity or odd parity. with even parity, an even number of 1s clears the parity bit and an odd number of 1s sets the parity bit. with odd parity, an odd number of 1s clears the parity bit and an even number of 1s sets the parity bit. 0 even parity 1 odd parity
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 385 rev 1.09 13.3.2.3 sci control register 2 (scicr2) read: anytime write: anytime table 13-3. loop functions loops rsrc function 0 x normal operation 1 0 loop mode with rx input internally connected to tx output 1 1 single-wire mode with rx input connected to txd module base + 0x_0003 76543210 r tie tcie rie ilie te re rwu sbk w reset 0 0 0 00000 figure 13-5. sci control register 2 (scicr2) table 13-4. scicr2 field descriptions field description 7 tie transmitter interrupt enable bit ?tie enables the transmit data register empty ?g, tdre, to generate interrupt requests. 0 tdre interrupt requests disabled 1 tdre interrupt requests enabled 6 tcie transmission complete interrupt enable bit tcie enables the transmission complete ?g, tc, to generate interrupt requests. 0 tc interrupt requests disabled 1 tc interrupt requests enabled 5 rie receiver full interrupt enable bit rie enables the receive data register full ?g, rdrf, or the overrun ?g, or, to generate interrupt requests. 0 rdrf and or interrupt requests disabled 1 rdrf and or interrupt requests enabled 4 ilie idle line interrupt enable bit ?ilie enables the idle line ?g, idle, to generate interrupt requests. 0 idle interrupt requests disabled 1 idle interrupt requests enabled 3 te transmitter enable bit ?te enables the sci transmitter and con?ures the txd pin as being controlled by the sci. the te bit can be used to queue an idle preamble. 0 transmitter disabled 1 transmitter enabled 2 re receiver enable bit ?re enables the sci receiver. 0 receiver disabled 1 receiver enabled
chapter 13 serial communications interface (s12sciv2) block description 386 mc9s12q128 freescale semiconductor rev 1.09 13.3.2.4 sci status register 1 (scisr1) the scisr1 and scisr2 registers provides inputs to the mcu for generation of sci interrupts. also, these registers can be polled by the mcu to check the status of these bits. the ?g-clearing procedures require that the status register be read followed by a read or write to the sci data register.it is permissible to execute other instructions between the two steps as long as it does not compromise the handling of i/o, but the order of operations is important for ?g clearing. read: anytime write: has no meaning or effect 1 rwu receiver wakeup bit ?standby state 0 normal operation. 1 rwu enables the wakeup function and inhibits further receiver interrupt requests. normally, hardware wakes the receiver by automatically clearing rwu. 0 sbk send break bit ?toggling sbk sends one break character (10 or 11 logic 0s, respectively 13 or 14 logics 0s if brk13 is set). toggling implies clearing the sbk bit before the break character has ?ished transmitting. as long as sbk is set, the transmitter continues to send complete break characters (10 or 11 bits, respectively 13 or 14 bits). 0 no break characters 1 transmit break characters module base + 0x_0004 76543210 r tdre tc rdrf idle or nf fe pf w reset 0 0 0 00000 = unimplemented or reserved figure 13-6. sci status register 1 (scisr1) table 13-5. scisr1 field descriptions field description 7 tdre transmit data register empty flag ?tdre is set when the transmit shift register receives a byte from the sci data register. when tdre is 1, the transmit data register (scidrh/l) is empty and can receive a new value to transmit.clear tdre by reading sci status register 1 (scisr1), with tdre set and then writing to sci data register low (scidrl). 0 no byte transferred to transmit shift register 1 byte transferred to transmit shift register; transmit data register empty 6 tc transmit complete flag tc is set low when there is a transmission in progress or when a preamble or break character is loaded. tc is set high when the tdre ?g is set and no data, preamble, or break character is being transmitted.when tc is set, the txd out signal becomes idle (logic 1). clear tc by reading sci status register 1 (scisr1) with tc set and then writing to sci data register low (scidrl). tc is cleared automatically when data, preamble, or break is queued and ready to be sent. tc is cleared in the event of a simultaneous set and clear of the tc ?g (transmission not complete). 0 transmission in progress 1 no transmission in progress table 13-4. scicr2 field descriptions (continued) field description
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 387 rev 1.09 5 rdrf receive data register full flag rdrf is set when the data in the receive shift register transfers to the sci data register. clear rdrf by reading sci status register 1 (scisr1) with rdrf set and then reading sci data register low (scidrl). 0 data not available in sci data register 1 received data available in sci data register 4 idle idle line flag ?idle is set when 10 consecutive logic 1s (if m=0) or 11 consecutive logic 1s (if m=1) appear on the receiver input. once the idle ?g is cleared, a valid frame must again set the rdrf ?g before an idle condition can set the idle ?g.clear idle by reading sci status register 1 (scisr1) with idle set and then reading sci data register low (scidrl). 0 receiver input is either active now or has never become active since the idle ?g was last cleared 1 receiver input has become idle note: when the receiver wakeup bit (rwu) is set, an idle line condition does not set the idle ?g. 3 or overrun flag ?or is set when software fails to read the sci data register before the receive shift register receives the next frame. the or bit is set immediately after the stop bit has been completely received for the second frame. the data in the shift register is lost, but the data already in the sci data registers is not affected. clear or by reading sci status register 1 (scisr1) with or set and then reading sci data register low (scidrl). 0 no overrun 1 overrun note: or ?g may read back as set when rdrf ?g is clear. this may happen if the following sequence of events occurs: 1. after the ?st frame is received, read status register scisr1 (returns rdrf set and or ?g clear); 2. receive second frame without reading the ?st frame in the data register (the second frame is not received and or ?g is set); 3. read data register scidrl (returns ?st frame and clears rdrf ?g in the status register); 4. read status register scisr1 (returns rdrf clear and or set). event 3 may be at exactly the same time as event 2 or any time after. when this happens, a dummy scidrl read following event 4 will be required to clear the or ?g if further frames are to be received. 2 nf noise flag nf is set when the sci detects noise on the receiver input. nf bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. clear nf by reading sci status register 1(scisr1), and then reading sci data register low (scidrl). 0 no noise 1 noise 1 fe framing error flag fe is set when a logic 0 is accepted as the stop bit. fe bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. fe inhibits further data reception until it is cleared. clear fe by reading sci status register 1 (scisr1) with fe set and then reading the sci data register low (scidrl). 0 no framing error 1 framing error 0 pf parity error flag pf is set when the parity enable bit (pe) is set and the parity of the received data does not match the parity type bit (pt). pf bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. clear pf by reading sci status register 1 (scisr1), and then reading sci data register low (scidrl). 0 no parity error 1 parity error table 13-5. scisr1 field descriptions (continued) field description
chapter 13 serial communications interface (s12sciv2) block description 388 mc9s12q128 freescale semiconductor rev 1.09 13.3.2.5 sci status register 2 (scisr2) read: anytime write: anytime; writing accesses sci status register 2; writing to any bits except txdir and brk13 (scisr2[1] & [2]) has no effect module base + 0x_0005 76543210 r00000 bk13 txdir raf w reset 0 0 0 00000 = unimplemented or reserved figure 13-7. sci status register 2 (scisr2) table 13-6. scisr2 field descriptions field description 2 bk13 break transmit character length ?this bit determines whether the transmit break character is 10 or 11 bit respectively 13 or 14 bits long. the detection of a framing error is not affected by this bit. 0 break character is 10 or 11 bit long 1 break character is 13 or 14 bit long 1 txdir transmitter pin data direction in single-wire mode. this bit determines whether the txd pin is going to be used as an input or output, in the single-wire mode of operation. this bit is only relevant in the single-wire mode of operation. 0 txd pin to be used as an input in single-wire mode 1 txd pin to be used as an output in single-wire mode 0 raf receiver active flag raf is set when the receiver detects a logic 0 during the rt1 time period of the start bit search. raf is cleared when the receiver detects an idle character. 0 no reception in progress 1 reception in progress
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 389 rev 1.09 13.3.2.6 sci data registers (scidrh and scidrl) read: anytime; reading accesses sci receive data register write: anytime; writing accesses sci transmit data register; writing to r8 has no effect note if the value of t8 is the same as in the previous transmission, t8 does not have to be rewritten.the same value is transmitted until t8 is rewritten in 8-bit data format, only sci data register low (scidrl) needs to be accessed. when transmitting in 9-bit data format and using 8-bit write instructions, write ?st to sci data register high (scidrh), then scidrl. module base + 0x_0006 76543210 rr8 t8 000000 w reset 0 0 0 00000 module base + 0x_0007 76543210 rr7r6r5r4r3r2r1r0 w t7 t6 t5 t4 t3 t2 t1 t0 reset 0 0 0 00000 = unimplemented or reserved figure 13-8. sci data registers (scidrh and scidrl) table 13-7. scidrh and scidrl field descriptions field description 7 r8 received bit 8 ?r8 is the ninth data bit received when the sci is con?ured for 9-bit data format (m = 1). 6 t8 transmit bit 8 ?t8 is the ninth data bit transmitted when the sci is con?ured for 9-bit data format (m = 1). 7? r[7:0] t[7:0] received bits ?received bits seven through zero for 9-bit or 8-bit data formats transmit bits ?transmit bits seven through zero for 9-bit or 8-bit formats
chapter 13 serial communications interface (s12sciv2) block description 390 mc9s12q128 freescale semiconductor rev 1.09 13.4 functional description this section provides a complete functional description of the sci block, detailing the operation of the design from the end user perspective in a number of subsections. figure 13-9 shows the structure of the sci module. the sci allows full duplex, asynchronous, nrz serial communication between the cpu and remote devices, including other cpus. the sci transmitter and receiver operate independently, although they use the same baud rate generator. the cpu monitors the status of the sci, writes the data to be transmitted, and processes received data. figure 13-9. sci block diagram sci data receive shift register sci data register transmit shift register register baud rate generator sbr12?br0 bus transmit control 16 receive and wakeup data format control control t8 pf fe nf rdrf idle tie or tcie tdre tc r8 raf loops rwu re pe ilt pt wake m clock ilie rie rxd rsrc sbk loops te rsrc txd rdrf/or irq tdre irq idle irq tc irq irq to cpu
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 391 rev 1.09 13.4.1 data format the sci uses the standard nrz mark/space data format illustrated in figure 13-10 below. figure 13-10. sci data formats each data character is contained in a frame that includes a start bit, eight or nine data bits, and a stop bit. clearing the m bit in sci control register 1 con?ures the sci for 8-bit data characters.a frame with eight data bits has a total of 10 bits. setting the m bit con?ures the sci for nine-bit data characters. a frame with nine data bits has a total of 11 bits when the sci is con?ured for 9-bit data characters, the ninth data bit is the t8 bit in sci data register high (scidrh). it remains unchanged after transmission and can be used repeatedly without rewriting it. a frame with nine data bits has a total of 11 bits. table 13-9. example of 9-bit data formats table 13-8. example of 8-bit data formats start bit data bits address bits parity bits stop bit 18 0 0 1 17 0 1 1 17 1 (1) 1. the address bit identi?s the frame as an address character. see section 13.4.4.6, ?eceiver wakeup . 01 start bit data bits address bits parity bits stop bit 19 0 0 1 18 0 1 1 18 1 (1) 1. the address bit identi?s the frame as an address character. see section 13.4.4.6, ?eceiver wakeup . 01 bit 5 start bit bit 0 bit 1 next stop bit start bit 9-bit data format bit 2 bit 3 bit 4 bit 6 bit 7 parity or data bit parity or data bit bit m in scicr1 set 8-bit data format bit m in scicr1 clear bit 5 bit 0 bit 1 bit 2 bit 3 bit 4 bit 6 bit 7 bit 8 stop bit next start bit start bit
chapter 13 serial communications interface (s12sciv2) block description 392 mc9s12q128 freescale semiconductor rev 1.09 13.4.2 baud rate generation a 13-bit modulus counter in the baud rate generator derives the baud rate for both the receiver and the transmitter. the value from 0 to 8191 written to the sbr12?br0 bits determines the module clock divisor. the sbr bits are in the sci baud rate registers (scibdh and scibdl). the baud rate clock is synchronized with the bus clock and drives the receiver. the baud rate clock divided by 16 drives the transmitter. the receiver has an acquisition rate of 16 samples per bit time. baud rate generation is subject to one source of error: integer division of the module clock may not give the exact target frequency. table 13-10 lists some examples of achieving target baud rates with a module clock frequency of 25 mhz sci baud rate = sci module clock / (16 * scibr[12:0]) table 13-10. baud rates (example: module clock = 25 mhz) bits sbr[12-0] receiver clock (hz) transmitter clock (hz) target baud rate error (%) 41 609,756.1 38,109.8 38,400 .76 81 308,642.0 19,290.1 19,200 .47 163 153,374.2 9585.9 9600 .16 326 76,687.1 4792.9 4800 .15 651 38,402.5 2400.2 2400 .01 1302 19,201.2 1200.1 1200 .01 2604 9600.6 600.0 600 .00 5208 4800.0 300.0 300 .00
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 393 rev 1.09 13.4.3 transmitter figure 13-11. transmitter block diagram 13.4.3.1 transmitter character length the sci transmitter can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (scicr1) determines the length of data characters. when transmitting 9-bit data, bit t8 in sci data register high (scidrh) is the ninth bit (bit 8). 13.4.3.2 character transmission to transmit data, the mcu writes the data bits to the sci data registers (scidrh/scidrl), which in turn are transferred to the transmitter shift register. the transmit shift register then shifts a frame out through the tx output signal, after it has prefaced them with a start bit and appended them with a stop bit. the sci data registers (scidrh and scidrl) are the write-only buffers between the internal data bus and the transmit shift register. the sci also sets a ?g, the transmit data register empty ?g (tdre), every time it transfers data from the buffer (scidrh/l) to the transmitter shift register.the transmit driver routine may respond to this ?g by pe pt h876543210l 11-bit transmit shift register stop start t8 tdre tie tcie sbk tc parity generation msb sci data registers load from scidr shift enable preamble (all ones) break (all 0s) transmitter control m internal bus sbr12?br0 baud divider 16 tdre interrupt request tc interrupt request bus loop rsrc clock te to control rxd loops txd
chapter 13 serial communications interface (s12sciv2) block description 394 mc9s12q128 freescale semiconductor rev 1.09 writing another byte to the transmitter buffer (scidrh/scidrl), while the shift register is still shifting out the ?st byte. to initiate an sci transmission: 1. con?ure the sci: a) select a baud rate. write this value to the sci baud registers (scibdh/l) to begin the baud rate generator. remember that the baud rate generator is disabled when the baud rate is zero. writing to the scibdh has no effect without also writing to scibdl. b) write to scicr1 to con?ure word length, parity, and other con?uration bits (loops,rsrc,m,wake,ilt,pe,pt). c) enable the transmitter, interrupts, receive, and wake up as required, by writing to the scicr2 register bits (tie,tcie,rie,ilie,te,re,rwu,sbk). a preamble or idle character will now be shifted out of the transmitter shift register. 2. transmit procedure for each byte: a. poll the tdre flag by reading the scisr1 or responding to the tdre interrupt. keep in mind that the tdre bit resets to one. d) if the tdre ?g is set, write the data to be transmitted to scidrh/l, where the ninth bit is written to the t8 bit in scidrh if the sci is in 9-bit data format. a new transmission will not result until the tdre ?g has been cleared. 3. repeat step 2 for each subsequent transmission. note the tdre ?g is set when the shift register is loaded with the next data to be transmitted from scidrh/l, which happens, generally speaking, a little over half-way through the stop bit of the previous frame. speci?ally, this transfer occurs 9/16ths of a bit time after the start of the stop bit of the previous frame. writing the te bit from 0 to a 1 automatically loads the transmit shift register with a preamble of 10 logic 1s (if m = 0) or 11 logic 1s (if m = 1). after the preamble shifts out, control logic transfers the data from the sci data register into the transmit shift register. a logic 0 start bit automatically goes into the least signi?ant bit position of the transmit shift register. a logic 1 stop bit goes into the most signi?ant bit position. hardware supports odd or even parity. when parity is enabled, the most signi?ant bit (msb) of the data character is the parity bit. the transmit data register empty ?g, tdre, in sci status register 1 (scisr1) becomes set when the sci data register transfers a byte to the transmit shift register. the tdre ?g indicates that the sci data register can accept new data from the internal data bus. if the transmit interrupt enable bit, tie, in sci control register 2 (scicr2) is also set, the tdre ?g generates a transmitter interrupt request. when the transmit shift register is not transmitting a frame, the tx output signal goes to the idle condition, logic 1. if at any time software clears the te bit in sci control register 2 (scicr2), the transmitter enable signal goes low and the transmit signal goes idle.
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 395 rev 1.09 if software clears te while a transmission is in progress (tc = 0), the frame in the transmit shift register continues to shift out. to avoid accidentally cutting off the last frame in a message, always wait for tdre to go high after the last frame before clearing te. to separate messages with preambles with minimum idle line time, use this sequence between messages: 1. write the last byte of the ?st message to scidrh/l. 2. wait for the tdre ?g to go high, indicating the transfer of the last frame to the transmit shift register. 3. queue a preamble by clearing and then setting the te bit. 4. write the ?st byte of the second message to scidrh/l. 13.4.3.3 break characters writing a logic 1 to the send break bit, sbk, in sci control register 2 (scicr2) loads the transmit shift register with a break character. a break character contains all logic 0s and has no start, stop, or parity bit. break character length depends on the m bit in sci control register 1 (scicr1). as long as sbk is at logic 1, transmitter logic continuously loads break characters into the transmit shift register. after software clears the sbk bit, the shift register ?ishes transmitting the last break character and then transmits at least one logic 1. the automatic logic 1 at the end of a break character guarantees the recognition of the start bit of the next frame. the sci recognizes a break character when a start bit is followed by eight or nine logic 0 data bits and a logic 0 where the stop bit should be. receiving a break character has these effects on sci registers: sets the framing error ?g, fe sets the receive data register full ?g, rdrf clears the sci data registers (scidrh/l) may set the overrun ?g, or, noise ?g, nf, parity error ?g, pe, or the receiver active ?g, raf (see section 13.3.2.4, ?ci status register 1 (scisr1) and section 13.3.2.5, ?ci status register 2 (scisr2) 13.4.3.4 idle characters an idle character contains all logic 1s and has no start, stop, or parity bit. idle character length depends on the m bit in sci control register 1 (scicr1). the preamble is a synchronizing idle character that begins the ?st transmission initiated after writing the te bit from 0 to 1. if the te bit is cleared during a transmission, the tx output signal becomes idle after completion of the transmission in progress. clearing and then setting the te bit during a transmission queues an idle character to be sent after the frame currently being transmitted.
chapter 13 serial communications interface (s12sciv2) block description 396 mc9s12q128 freescale semiconductor rev 1.09 note when queueing an idle character, return the te bit to logic 1 before the stop bit of the current frame shifts out through the tx output signal. setting te after the stop bit appears on tx output signal causes data previously written to the sci data register to be lost. toggle the te bit for a queued idle character while the tdre ?g is set and immediately before writing the next byte to the sci data register. note if the te bit is clear and the transmission is complete, the sci is not the master of the txd pin 13.4.4 receiver figure 13-12. sci receiver block diagram 13.4.4.1 receiver character length the sci receiver can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (scicr1) determines the length of data characters. when receiving 9-bit data, bit r8 in sci data register high (scidrh) is the ninth bit (bit 8). all ones m wake ilt pe pt re h876543210l 11-bit receive shift register stop start data wakeup parity checking msb sci data register r8 rie ilie rwu rdrf or nf fe pe internal bus bus idle interrupt request rdrf/or interrupt request sbr12?br0 baud divider loop rsrc from txd clock idle raf recovery control logic loops rxd
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 397 rev 1.09 13.4.4.2 character reception during an sci reception, the receive shift register shifts a frame in from the rx input signal. the sci data register is the read-only buffer between the internal data bus and the receive shift register. after a complete frame shifts into the receive shift register, the data portion of the frame transfers to the sci data register. the receive data register full ?g, rdrf, in sci status register 1 (scisr1) becomes set, indicating that the received byte can be read. if the receive interrupt enable bit, rie, in sci control register 2 (scicr2) is also set, the rdrf ?g generates an rdrf interrupt request. 13.4.4.3 data sampling the receiver samples the rx input signal at the rt clock rate. the rt clock is an internal signal with a frequency 16 times the baud rate. to adjust for baud rate mismatch, the rt clock (see figure 13-13 ) is re- synchronized: after every start bit after the receiver detects a data bit change from logic 1 to logic 0 (after the majority of data bit samples at rt8, rt9, and rt10 returns a valid logic 1 and the majority of the next rt8, rt9, and rt10 samples returns a valid logic 0) to locate the start bit, data recovery logic does an asynchronous search for a logic 0 preceded by three logic 1s.when the falling edge of a possible start bit occurs, the rt clock begins to count to 16. figure 13-13. receiver data sampling to verify the start bit and to detect noise, data recovery logic takes samples at rt3, rt5, and rt7. table 13-11 summarizes the results of the start bit veri?ation samples. table 13-11. start bit veri?ation rt3, rt5, and rt7 samples start bit veri?ation noise flag 000 yes 0 001 yes 1 010 yes 1 011 no 0 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt8 rt7 rt6 rt11 rt10 rt9 rt15 rt14 rt13 rt12 rt16 rt1 rt2 rt3 rt4 samples rt clock rt clock count start bit rx input signal start bit qualification start bit data sampling 11 1 1 1 1 110000 0 00 lsb verification
chapter 13 serial communications interface (s12sciv2) block description 398 mc9s12q128 freescale semiconductor rev 1.09 if start bit veri?ation is not successful, the rt clock is reset and a new search for a start bit begins. to determine the value of a data bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 13-12 summarizes the results of the data bit samples. note the rt8, rt9, and rt10 samples do not affect start bit veri?ation. if any or all of the rt8, rt9, and rt10 start bit samples are logic 1s following a successful start bit veri?ation, the noise ?g (nf) is set and the receiver assumes that the bit is a start bit (logic 0). to verify a stop bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 13-13 summarizes the results of the stop bit samples. table 13-13. stop bit recovery 100 yes 1 101 no 0 110 no 0 111 no 0 table 13-12. data bit recovery rt8, rt9, and rt10 samples data bit determination noise flag 000 0 0 001 0 1 010 0 1 011 1 1 100 0 1 101 1 1 110 1 1 111 1 0 rt8, rt9, and rt10 samples framing error flag noise flag 000 1 0 001 1 1 010 1 1 011 0 1 100 1 1 101 0 1 110 0 1 111 0 0 table 13-11. start bit veri?ation rt3, rt5, and rt7 samples start bit veri?ation noise flag
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 399 rev 1.09 in figure 13-14 the veri?ation samples rt3 and rt5 determine that the ?st low detected was noise and not the beginning of a start bit. the rt clock is reset and the start bit search begins again. the noise ?g is not set because the noise occurred before the start bit was found. figure 13-14. start bit search example 1 in figure 13-15 , veri?ation sample at rt3 is high. the rt3 sample sets the noise ?g. although the perceived bit time is misaligned, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. figure 13-15. start bit search example 2 reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rx input signal 11 0 1 111000 00 lsb 0 0 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt11 rt10 rt9 rt14 rt13 rt12 rt2 rt1 rt16 rt15 rt3 rt4 rt5 rt6 rt7 samples rt clock rt clock count actual start bit rx input signal 11 1 1 11000 0 lsb 0 0 perceived start bit
chapter 13 serial communications interface (s12sciv2) block description 400 mc9s12q128 freescale semiconductor rev 1.09 in figure 13-16 , a large burst of noise is perceived as the beginning of a start bit, although the test sample at rt5 is high. the rt5 sample sets the noise ?g. although this is a worst-case misalignment of perceived bit time, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. figure 13-16. start bit search example 3 figure 13-17 shows the effect of noise early in the start bit time. although this noise does not affect proper synchronization with the start bit time, it does set the noise ?g. figure 13-17. start bit search example 4 reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt13 rt12 rt11 rt16 rt15 rt14 rt4 rt3 rt2 rt1 rt5 rt6 rt7 rt8 rt9 samples rt clock rt clock count actual start bit rx input signal 10 1 11000 0 lsb 0 perceived start bit reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count perceived and actual start bit rx input signal 11 1 1100 1 lsb 1 1 1 1
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 401 rev 1.09 figure 13-18 shows a burst of noise near the beginning of the start bit that resets the rt clock. the sample after the reset is low but is not preceded by three high samples that would qualify as a falling edge. depending on the timing of the start bit search and on the data, the frame may be missed entirely or it may set the framing error ?g. figure 13-18. start bit search example 5 in figure 13-19 , a noise burst makes the majority of data samples rt8, rt9, and rt10 high. this sets the noise ?g but does not reset the rt clock. in start bits only, the rt8, rt9, and rt10 data samples are ignored. figure 13-19. start bit search example 6 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 samples rt clock rt clock count start bit rx input signal 11 1 1101 0 lsb 1 1 1 1 1 00 0 00 0 0 0 no start bit found reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rx input signal 11 1 1100 0 lsb 1 1 1 1 0 11 0
chapter 13 serial communications interface (s12sciv2) block description 402 mc9s12q128 freescale semiconductor rev 1.09 13.4.4.4 framing errors if the data recovery logic does not detect a logic 1 where the stop bit should be in an incoming frame, it sets the framing error ?g, fe, in sci status register 1 (scisr1). a break character also sets the fe ?g because a break character has no stop bit. the fe ?g is set at the same time that the rdrf ?g is set. 13.4.4.5 baud rate tolerance a transmitting device may be operating at a baud rate below or above the receiver baud rate. accumulated bit time misalignment can cause one of the three stop bit data samples (rt8, rt9, and rt10) to fall outside the actual stop bit.a noise error will occur if the rt8, rt9, and rt10 samples are not all the same logical values. a framing error will occur if the receiver clock is misaligned in such a way that the majority of the rt8, rt9, and rt10 stop bit samples are a logic zero. as the receiver samples an incoming frame, it re-synchronizes the rt clock on any valid falling edge within the frame. re synchronization within frames will correct a misalignment between transmitter bit times and receiver bit times. 13.4.4.5.1 slow data tolerance figure 13-20 shows how much a slow received frame can be misaligned without causing a noise error or a framing error. the slow stop bit begins at rt8 instead of rt1 but arrives in time for the stop bit data samples at rt8, rt9, and rt10. figure 13-20. slow data lets take rtr as receiver rt clock and rtt as transmitter rt clock. for an 8-bit data character, it takes the receiver 9 bit times x 16 rtr cycles +7 rtr cycles =151 rtr cycles to start data sampling of the stop bit. with the misaligned character shown in figure 13-20 , the receiver counts 151 rtr cycles at the point when the count of the transmitting device is 9 bit times x 16 rtt cycles = 144 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 8-bit data character with no errors is: ((151 ?144) / 151) x 100 = 4.63% for a 9-bit data character, it takes the receiver 10 bit times x 16 rtr cycles + 7 rtr cycles = 167 rtr cycles to start data sampling of the stop bit. msb stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 403 rev 1.09 with the misaligned character shown in figure 13-20 , the receiver counts 167 rtr cycles at the point when the count of the transmitting device is 10 bit times x 16 rtt cycles = 160 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 9-bit character with no errors is: ((167 ?160) / 167) x 100 = 4.19% 13.4.4.5.2 fast data tolerance figure 13-21 shows how much a fast received frame can be misaligned. the fast stop bit ends at rt10 instead of rt16 but is still sampled at rt8, rt9, and rt10. figure 13-21. fast data for an 8-bit data character, it takes the receiver 9 bit times x 16 rtr cycles + 10 rtr cycles = 154 rtr cycles to ?ish data sampling of the stop bit. with the misaligned character shown in figure 13-21 , the receiver counts 154 rtr cycles at the point when the count of the transmitting device is 10 bit times x 16 rtt cycles = 160 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 8-bit character with no errors is: ((160 ?154) / 160) x 100 = 3.75% for a 9-bit data character, it takes the receiver 10 bit times x 16 rtr cycles + 10 rtr cycles = 170 rtr cycles to ?ish data sampling of the stop bit. with the misaligned character shown in figure 13-21 , the receiver counts 170 rtr cycles at the point when the count of the transmitting device is 11 bit times x 16 rtt cycles = 176 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 9-bit character with no errors is: ((176 ?170) / 176) x 100 = 3.40% 13.4.4.6 receiver wakeup to enable the sci to ignore transmissions intended only for other receivers in multiple-receiver systems, the receiver can be put into a standby state. setting the receiver wakeup bit, rwu, in sci control register 2 (scicr2) puts the receiver into standby state during which receiver interrupts are disabled.the sci will still load the receive data into the scidrh/l registers, but it will not set the rdrf ?g. idle or next frame stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock
chapter 13 serial communications interface (s12sciv2) block description 404 mc9s12q128 freescale semiconductor rev 1.09 the transmitting device can address messages to selected receivers by including addressing information in the initial frame or frames of each message. the wake bit in sci control register 1 (scicr1) determines how the sci is brought out of the standby state to process an incoming message. the wake bit enables either idle line wakeup or address mark wakeup. 13.4.4.6.1 idle input line wakeup (wake = 0) in this wakeup method, an idle condition on the rx input signal clears the rwu bit and wakes up the sci. the initial frame or frames of every message contain addressing information. all receivers evaluate the addressing information, and receivers for which the message is addressed process the frames that follow. any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the rwu bit remains set and the receiver remains on standby until another idle character appears on the rx input signal. idle line wakeup requires that messages be separated by at least one idle character and that no message contains idle characters. the idle character that wakes a receiver does not set the receiver idle bit, idle, or the receive data register full ?g, rdrf. the idle line type bit, ilt, determines whether the receiver begins counting logic 1s as idle character bits after the start bit or after the stop bit. ilt is in sci control register 1 (scicr1). 13.4.4.6.2 address mark wakeup (wake = 1) in this wakeup method, a logic 1 in the most signi?ant bit (msb) position of a frame clears the rwu bit and wakes up the sci. the logic 1 in the msb position marks a frame as an address frame that contains addressing information. all receivers evaluate the addressing information, and the receivers for which the message is addressed process the frames that follow.any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the rwu bit remains set and the receiver remains on standby until another address frame appears on the rx input signal. the logic 1 msb of an address frame clears the receivers rwu bit before the stop bit is received and sets the rdrf ?g. address mark wakeup allows messages to contain idle characters but requires that the msb be reserved for use in address frames.{sci_wake} note with the wake bit clear, setting the rwu bit after the rx input signal has been idle can cause the receiver to wake up immediately.
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 405 rev 1.09 13.4.5 single-wire operation normally, the sci uses two pins for transmitting and receiving. in single-wire operation, the rxd pin is disconnected from the sci. the sci uses the txd pin for both receiving and transmitting. figure 13-22. single-wire operation (loops = 1, rsrc = 1) enable single-wire operation by setting the loops bit and the receiver source bit, rsrc, in sci control register 1 (scicr1). setting the loops bit disables the path from the rx input signal to the receiver. setting the rsrc bit connects the receiver input to the output of the txd pin driver. both the transmitter and receiver must be enabled (te = 1 and re = 1).the txdir bit (scisr2[1]) determines whether the txd pin is going to be used as an input (txdir = 0) or an output (txdir = 1) in this mode of operation. 13.4.6 loop operation in loop operation the transmitter output goes to the receiver input. the rx input signal is disconnected from the sci . figure 13-23. loop operation (loops = 1, rsrc = 0) enable loop operation by setting the loops bit and clearing the rsrc bit in sci control register 1 (scicr1). setting the loops bit disables the path from the rx input signal to the receiver. clearing the rsrc bit connects the transmitter output to the receiver input. both the transmitter and receiver must be enabled (te = 1 and re = 1). 13.5 initialization information 13.5.1 reset initialization the reset state of each individual bit is listed in section 13.3, ?emory map and registers which details the registers and their bit ?lds. all special functions or modes which are initialized during or just following reset are described within this section. rxd transmitter receiver tx output signal tx input signal rxd transmitter receiver tx output signal
chapter 13 serial communications interface (s12sciv2) block description 406 mc9s12q128 freescale semiconductor rev 1.09 13.5.2 interrupt operation 13.5.2.1 system level interrupt sources there are ve interrupt sources that can generate an sci interrupt in to the cpu. they are listed in table 13-14 . table 13-14. sci interrupt source interrupt source flag local enable transmitter tdre tie transmitter tc tcie receiver rdrf rie or receiver idle ilie
chapter 13 serial communications interface (s12sciv2) block description freescale semiconductor mc9s12q128 407 rev 1.09 13.5.2.2 interrupt descriptions the sci only originates interrupt requests. the following is a description of how the sci makes a request and how the mcu should acknowledge that request. the interrupt vector offset and interrupt number are chip dependent. the sci only has a single interrupt line ( sci interrupt signal , active high operation) and all the following interrupts, when generated, are ored together and issued through that port. 13.5.2.2.1 tdre description the tdre interrupt is set high by the sci when the transmit shift register receives a byte from the sci data register. a tdre interrupt indicates that the transmit data register (scidrh/l) is empty and that a new byte can be written to the scidrh/l for transmission.clear tdre by reading sci status register 1 with tdre set and then writing to sci data register low (scidrl). 13.5.2.2.2 tc description the tc interrupt is set by the sci when a transmission has been completed.a tc interrupt indicates that there is no transmission in progress. tc is set high when the tdre ?g is set and no data, preamble, or break character is being transmitted. when tc is set, the txd pin becomes idle (logic 1). clear tc by reading sci status register 1 (scisr1) with tc set and then writing to sci data register low (scidrl).tc is cleared automatically when data, preamble, or break is queued and ready to be sent. 13.5.2.2.3 rdrf description the rdrf interrupt is set when the data in the receive shift register transfers to the sci data register. a rdrf interrupt indicates that the received data has been transferred to the sci data register and that the byte can now be read by the mcu. the rdrf interrupt is cleared by reading the sci status register one (scisr1) and then reading sci data register low (scidrl). 13.5.2.2.4 or description the or interrupt is set when software fails to read the sci data register before the receive shift register receives the next frame. the newly acquired data in the shift register will be lost in this case, but the data already in the sci data registers is not affected. the or interrupt is cleared by reading the sci status register one (scisr1) and then reading sci data register low (scidrl). 13.5.2.3 idle description the idle interrupt is set when 10 consecutive logic 1s (if m = 0) or 11 consecutive logic 1s (if m = 1) appear on the receiver input. once the idle is cleared, a valid frame must again set the rdrf ?g before an idle condition can set the idle ?g. clear idle by reading sci status register 1 (scisr1) with idle set and then reading sci data register low (scidrl). 13.5.3 recovery from wait mode the sci interrupt request can be used to bring the cpu out of wait mode.
chapter 13 serial communications interface (s12sciv2) block description 408 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 409 rev 1.09 chapter 14 serial peripheral interface (spiv3) block description 14.1 introduction the spi module allows a duplex, synchronous, serial communication between the mcu and peripheral devices. software can poll the spi status ?gs or the spi operation can be interrupt driven. 14.1.1 features the spiv3 includes these distinctive features: master mode and slave mode bidirectional mode slave select output mode fault error ?g with cpu interrupt capability double-buffered data register serial clock with programmable polarity and phase control of spi operation during wait mode 14.1.2 modes of operation the spi functions in three modes, run, wait, and stop. run mode this is the basic mode of operation. wait mode spi operation in wait mode is a con?urable low power mode, controlled by the spiswai bit located in the spicr2 register. in wait mode, if the spiswai bit is clear, the spi operates like in run mode. if the spiswai bit is set, the spi goes into a power conservative state, with the spi clock generation turned off. if the spi is con?ured as a master, any transmission in progress stops, but is resumed after cpu goes into run mode. if the spi is con?ured as a slave, reception and transmission of a byte continues, so that the slave stays synchronized to the master. stop mode the spi is inactive in stop mode for reduced power consumption. if the spi is con?ured as a master, any transmission in progress stops, but is resumed after cpu goes into run mode. if the spi is con?ured as a slave, reception and transmission of a byte continues, so that the slave stays synchronized to the master. this is a high level description only, detailed descriptions of operating modes are contained in section 14.4, ?unctional description .
chapter 14 serial peripheral interface (spiv3) block description 410 mc9s12q128 freescale semiconductor rev 1.09 14.1.3 block diagram figure 14-1 gives an overview on the spi architecture. the main parts of the spi are status, control, and data registers, shifter logic, baud rate generator, master/slave control logic, and port control logic. figure 14-1. spi block diagram 14.2 external signal description this section lists the name and description of all ports including inputs and outputs that do, or may, connect off chip. the spiv3 module has a total of four external pins. 14.2.1 mosi ?master out/slave in pin this pin is used to transmit data out of the spi module when it is con?ured as a master and receive data when it is con?ured as slave. spi control register 1 spi control register 2 spi baud rate register spi status register spi data register shifter port control logic mosi sck interrupt control spi msb lsb lsbfe=1 lsbfe=0 lsbfe=0 lsbfe=1 data in lsbfe=1 lsbfe=0 data out 8 8 baud rate generator prescaler bus clock counter clock select sppr 3 3 spr baud rate phase + polarity control master slave sck in sck out master baud rate slave baud rate phase + polarity control control control cpol cpha 2 bidiroe spc0 2 modf spif sptef spi request interrupt ss shift clock sample clock
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 411 rev 1.09 14.2.2 miso ?master in/slave out pin this pin is used to transmit data out of the spi module when it is con?ured as a slave and receive data when it is con?ured as master. 14.2.3 ss ?slave select pin this pin is used to output the select signal from the spi module to another peripheral with which a data transfer is to take place when its con?ured as a master and its used as an input to receive the slave select signal when the spi is con?ured as slave. 14.2.4 sck ?serial clock pin this pin is used to output the clock with respect to which the spi transfers data or receive clock in case of slave. 14.3 memory map and register de?ition this section provides a detailed description of address space and registers used by the spi. the memory map for the spiv3 is given below in table 14-1 . the address listed for each register is the sum of a base address and an address offset. the base address is de?ed at the soc level and the address offset is de?ed at the module level. reads from the reserved bits return zeros and writes to the reserved bits have no effect. 14.3.1 module memory map table 14-1. spiv3 memory map address use access 0x0000 spi control register 1 (spicr1) r/w 0x0001 spi control register 2 (spicr2) r/w (1) 1. certain bits are non-writable. 0x0002 spi baud rate register (spibr) r/w 1 0x0003 spi status register (spisr) r (2) 2. writes to this register are ignored. 0x0004 reserved 2,(3) 3. reading from this register returns all zeros. 0x0005 spi data register (spidr) r/w 0x0006 reserved 2,3 0x0007 reserved 2,3
chapter 14 serial peripheral interface (spiv3) block description 412 mc9s12q128 freescale semiconductor rev 1.09 14.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. 14.3.2.1 spi control register 1 (spicr1) read: anytime write: anytime name 7 6 5 4 3 2 1 0 0x0000 spicr1 r spie spe sptie mstr cpol cpha ssoe lsbfe w 0x0001 spicr2 r0 0 0 modfen bidiroe 0 spiswai spc0 w 0x0002 spibr r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w 0x0003 spisr r spif 0 sptef modf 0 0 0 0 w 0x0004 reserved r w 0x0005 spidr r bit 7 6 5 4 3 2 2 bit 0 w 0x0006 reserved r w 0x0007 reserved r w = unimplemented or reserved figure 14-2. spi register summary module base 0x0000 76543210 r spie spe sptie mstr cpol cpha ssoe lsbfe w reset 0 0 0 00100 figure 14-3. spi control register 1 (spicr1)
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 413 rev 1.09 table 14-2. spicr1 field descriptions field description 7 spie spi interrupt enable bit ?this bit enables spi interrupt requests, if spif or modf status ?g is set. 0 spi interrupts disabled. 1 spi interrupts enabled. 6 spe spi system enable bit ?this bit enables the spi system and dedicates the spi port pins to spi system functions. if spe is cleared, spi is disabled and forced into idle state, status bits in spisr register are reset. 0 spi disabled (lower power consumption). 1 spi enabled, port pins are dedicated to spi functions. 5 sptie spi transmit interrupt enable ?this bit enables spi interrupt requests, if sptef ?g is set. 0 sptef interrupt disabled. 1 sptef interrupt enabled. 4 mstr spi master/slave mode select bit ?this bit selects, if the spi operates in master or slave mode. switching the spi from master to slave or vice versa forces the spi system into idle state. 0 spi is in slave mode 1 spi is in master mode 3 cpol spi clock polarity bit this bit selects an inverted or non-inverted spi clock. to transmit data between spi modules, the spi modules must have identical cpol values. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 active-high clocks selected. in idle state sck is low. 1 active-low clocks selected. in idle state sck is high. 2 cpha spi clock phase bit this bit is used to select the spi clock format. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 sampling of data occurs at odd edges (1,3,5,...,15) of the sck clock 1 sampling of data occurs at even edges (2,4,6,...,16) of the sck clock 1 ssoe slave select output enable ?the ss output feature is enabled only in master mode, if modfen is set, by asserting the ssoe as shown in table 14-3 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 lsbfe lsb-first enable ?this bit does not affect the position of the msb and lsb in the data register. reads and writes of the data register always have the msb in bit 7. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 data is transferred most signi?ant bit ?st. 1 data is transferred least signi?ant bit ?st. table 14-3. ss input / output selection modfen ssoe master mode slave mode 00 ss not used by spi ss input 01 ss not used by spi ss input 10 ss input with modf feature ss input 11 ss is slave select output ss input
chapter 14 serial peripheral interface (spiv3) block description 414 mc9s12q128 freescale semiconductor rev 1.09 14.3.2.2 spi control register 2 (spicr2) read: anytime write: anytime; writes to the reserved bits have no effect module base 0x0001 76543210 r000 modfen bidiroe 0 spiswai spc0 w reset 0 0 0 00000 = unimplemented or reserved figure 14-4. spi control register 2 (spicr2) table 14-4. spicr2 field descriptions field description 4 modfen mode fault enable bit ?this bit allows the modf failure being detected. if the spi is in master mode and modfen is cleared, then the ss port pin is not used by the spi. in slave mode, the ss is available only as an input regardless of the value of modfen. for an overview on the impact of the modfen bit on the ss port pin con?uration refer to table 14-3 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 ss port pin is not used by the spi 1 ss port pin with modf feature 3 bidiroe output enable in the bidirectional mode of operation this bit controls the mosi and miso output buffer of the spi, when in bidirectional mode of operation (spc0 is set). in master mode this bit controls the output buffer of the mosi port, in slave mode it controls the output buffer of the miso port. in master mode, with spc0 set, a change of this bit will abort a transmission in progress and force the spi into idle state. 0 output buffer disabled 1 output buffer enabled 1 spiswai spi stop in wait mode bit ?this bit is used for power conservation while in wait mode. 0 spi clock operates normally in wait mode 1 stop spi clock generation when in wait mode 0 spc0 serial pin control bit 0 ?this bit enables bidirectional pin con?urations as shown in table 14-5 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state table 14-5. bidirectional pin con?urations pin mode spc0 bidiroe miso mosi master mode of operation normal 0 x master in master out bidirectional 1 0 miso not used by spi master in 1 master i/o slave mode of operation normal 0 x slave out slave in
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 415 rev 1.09 14.3.2.3 spi baud rate register (spibr) read: anytime write: anytime; writes to the reserved bits have no effect the baud rate divisor equation is as follows: the baud rate can be calculated with the following equation: bidirectional 1 0 slave in mosi not used by spi 1 slave i/o module base 0x0002 76543210 r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w reset 0 0 0 00000 = unimplemented or reserved figure 14-5. spi baud rate register (spibr) table 14-6. spibr field descriptions field description 6:4 sppr[2:0] spi baud rate preselection bits ?these bits specify the spi baud rates as shown in table 14-7 . in master mode, a change of these bits will abort a transmission in progress and force the spi system into idle state. 2:0 spr[2:0} spi baud rate selection bits these bits specify the spi baud rates as shown in table 14-7 . in master mode, a change of these bits will abort a transmission in progress and force the spi system into idle state. table 14-5. bidirectional pin con?urations (continued) pin mode spc0 bidiroe miso mosi baudratedivisor sppr 1 + () 2 ? spr 1 + () = baud rate busclock baudratedivisor ? =
chapter 14 serial peripheral interface (spiv3) block description 416 mc9s12q128 freescale semiconductor rev 1.09 table 14-7. example spi baud rate selection (25 mhz bus clock) sppr2 sppr1 sppr0 spr2 spr1 spr0 baud rate divisor baud rate 0000002 12.5 mhz 0000014 6.25 mhz 0000108 3.125 mhz 00001116 1.5625 mhz 00010032 781.25 khz 00010164 390.63 khz 000110128 195.31 khz 000111256 97.66 khz 0010004 6.25 mhz 0010018 3.125 mhz 00101016 1.5625 mhz 00101132 781.25 khz 00110064 390.63 khz 001101128 195.31 khz 001110256 97.66 khz 001111512 48.83 khz 0100006 4.16667 mhz 01000112 2.08333 mhz 01001024 1.04167 mhz 01001148 520.83 khz 01010096 260.42 khz 010101192 130.21 khz 010110384 65.10 khz 010111768 32.55 khz 0110008 3.125 mhz 01100116 1.5625 mhz 01101032 781.25 khz 01101164 390.63 khz 011100128 195.31 khz 011101256 97.66 khz 011110512 48.83 khz 011111 1024 24.41 khz 10000010 2.5 mhz 10000120 1.25 mhz 10001040 625 khz 10001180 312.5 khz 100100160 156.25 khz 100101320 78.13 khz 100110640 39.06 khz
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 417 rev 1.09 note in slave mode of spi s-clock speed div2 is not supported. 100111 1280 19.53 khz 10100012 2.08333 mhz 10100124 1.04167 mhz 10101048 520.83 khz 10101196 260.42 khz 101100192 130.21 khz 101101384 65.10 khz 101110768 32.55 khz 101111 1536 16.28 khz 11000014 1.78571 mhz 11000128 892.86 khz 11001056 446.43 khz 110011112 223.21 khz 110100224 111.61 khz 110101448 55.80 khz 110110896 27.90 khz 110111 1792 13.95 khz 11100016 1.5625 mhz 11100132 781.25 khz 11101064 390.63 khz 111011128 195.31 khz 111100256 97.66 khz 111101512 48.83 khz 111110 1024 24.41 khz 111111 2048 12.21 khz table 14-7. example spi baud rate selection (25 mhz bus clock) (continued) sppr2 sppr1 sppr0 spr2 spr1 spr0 baud rate divisor baud rate
chapter 14 serial peripheral interface (spiv3) block description 418 mc9s12q128 freescale semiconductor rev 1.09 14.3.2.4 spi status register (spisr) read: anytime write: has no effect 14.3.2.5 spi data register (spidr) read: anytime; normally read only after spif is set module base 0x0003 76543210 r spif 0 sptef modf 0000 w reset 0 0 1 00000 = unimplemented or reserved figure 14-6. spi status register (spisr) table 14-8. spisr field descriptions field description 7 spif spif interrupt flag this bit is set after a received data byte has been transferred into the spi data register. this bit is cleared by reading the spisr register (with spif set) followed by a read access to the spi data register. 0 transfer not yet complete 1 new data copied to spidr 5 sptef spi transmit empty interrupt flag if set, this bit indicates that the transmit data register is empty. to clear this bit and place data into the transmit data register, spisr has to be read with sptef = 1, followed by a write to spidr. any write to the spi data register without reading sptef = 1, is effectively ignored. 0 spi data register not empty 1 spi data register empty 4 modf mode fault flag this bit is set if the ss input becomes low while the spi is con?ured as a master and mode fault detection is enabled, modfen bit of spicr2 register is set. refer to modfen bit description in section 14.3.2.2, ?pi control register 2 (spicr2) . the ?g is cleared automatically by a read of the spi status register (with modf set) followed by a write to the spi control register 1. 0 mode fault has not occurred. 1 mode fault has occurred. module base 0x0005 76543210 r bit 7 6 5 4322 bit 0 w reset 0 0 0 00000 = unimplemented or reserved figure 14-7. spi data register (spidr)
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 419 rev 1.09 write: anytime the spi data register is both the input and output register for spi data. a write to this register allows a data byte to be queued and transmitted. for a spi con?ured as a master, a queued data byte is transmitted immediately after the previous transmission has completed. the spi transmitter empty flag sptef in the spisr register indicates when the spi data register is ready to accept new data. reading the data can occur anytime from after the spif is set to before the end of the next transfer. if the spif is not serviced by the end of the successive transfers, those data bytes are lost and the data within the spidr retains the ?st byte until spif is serviced. 14.4 functional description the spi module allows a duplex, synchronous, serial communication between the mcu and peripheral devices. software can poll the spi status ?gs or spi operation can be interrupt driven. the spi system is enabled by setting the spi enable (spe) bit in spi control register 1. while spe bit is set, the four associated spi port pins are dedicated to the spi function as: slave select ( ss) serial clock (sck) master out/slave in (mosi) master in/slave out (miso) the main element of the spi system is the spi data register. the 8-bit data register in the master and the 8-bit data register in the slave are linked by the mosi and miso pins to form a distributed 16-bit register. when a data transfer operation is performed, this 16-bit register is serially shifted eight bit positions by the s-clock from the master, so data is exchanged between the master and the slave. data written to the master spi data register becomes the output data for the slave, and data read from the master spi data register after a transfer operation is the input data from the slave. a read of spisr with sptef = 1 followed by a write to spidr puts data into the transmit data register. when a transfer is complete, received data is moved into the receive data register. data may be read from this double-buffered system any time before the next transfer has completed. this 8-bit data register acts as the spi receive data register for reads and as the spi transmit data register for writes. a single spi register address is used for reading data from the read data buffer and for writing data to the transmit data register. the clock phase control bit (cpha) and a clock polarity control bit (cpol) in the spi control register 1 (spicr1) select one of four possible clock formats to be used by the spi system. the cpol bit simply selects a non-inverted or inverted clock. the cpha bit is used to accommodate two fundamentally different protocols by sampling data on odd numbered sck edges or on even numbered sck edges (see section 14.4.3, ?ransmission formats ). the spi can be con?ured to operate as a master or as a slave. when the mstr bit in spi control register1 is set, master mode is selected, when the mstr bit is clear, slave mode is selected.
chapter 14 serial peripheral interface (spiv3) block description 420 mc9s12q128 freescale semiconductor rev 1.09 14.4.1 master mode the spi operates in master mode when the mstr bit is set. only a master spi module can initiate transmissions. a transmission begins by writing to the master spi data register. if the shift register is empty, the byte immediately transfers to the shift register. the byte begins shifting out on the mosi pin under the control of the serial clock. s-clock the spr2, spr1, and spr0 baud rate selection bits in conjunction with the sppr2, sppr1, and sppr0 baud rate preselection bits in the spi baud rate register control the baud rate generator and determine the speed of the transmission. the sck pin is the spi clock output. through the sck pin, the baud rate generator of the master controls the shift register of the slave peripheral. mosi and miso pins in master mode, the function of the serial data output pin (mosi) and the serial data input pin (miso) is determined by the spc0 and bidiroe control bits. ss pin if modfen and ssoe bit are set, the ss pin is con?ured as slave select output. the ss output becomes low during each transmission and is high when the spi is in idle state. if modfen is set and ssoe is cleared, the ss pin is con?ured as input for detecting mode fault error. if the ss input becomes low this indicates a mode fault error where another master tries to drive the mosi and sck lines. in this case, the spi immediately switches to slave mode, by clearing the mstr bit and also disables the slave output buffer miso (or siso in bidirectional mode). so the result is that all outputs are disabled and sck, mosi and miso are inputs. if a transmission is in progress when the mode fault occurs, the transmission is aborted and the spi is forced into idle state. this mode fault error also sets the mode fault (modf) ?g in the spi status register (spisr). if the spi interrupt enable bit (spie) is set when the modf ?g gets set, then an spi interrupt sequence is also requested. when a write to the spi data register in the master occurs, there is a half sck-cycle delay. after the delay, sck is started within the master. the rest of the transfer operation differs slightly, depending on the clock format speci?d by the spi clock phase bit, cpha, in spi control register 1 (see section 14.4.3, ?ransmission formats ). note a change of the bits cpol, cpha, ssoe, lsbfe, modfen, spc0, bidiroe with spc0 set, sppr2?ppr0 and spr2?pr0 in master mode will abort a transmission in progress and force the spi into idle state. the remote slave cannot detect this, therefore the master has to ensure that the remote slave is set back to idle state.
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 421 rev 1.09 14.4.2 slave mode the spi operates in slave mode when the mstr bit in spi control register1 is clear. sck clock in slave mode, sck is the spi clock input from the master. miso and mosi pins in slave mode, the function of the serial data output pin (miso) and serial data input pin (mosi) is determined by the spc0 bit and bidiroe bit in spi control register 2. ss pin the ss pin is the slave select input. before a data transmission occurs, the ss pin of the slave spi must be low. ss must remain low until the transmission is complete. if ss goes high, the spi is forced into idle state. the ss input also controls the serial data output pin, if ss is high (not selected), the serial data output pin is high impedance, and, if ss is low the ?st bit in the spi data register is driven out of the serial data output pin. also, if the slave is not selected ( ss is high), then the sck input is ignored and no internal shifting of the spi shift register takes place. although the spi is capable of duplex operation, some spi peripherals are capable of only receiving spi data in a slave mode. for these simpler devices, there is no serial data out pin. note when peripherals with duplex capability are used, take care not to simultaneously enable two receivers whose serial outputs drive the same system slaves serial data output line. as long as no more than one slave device drives the system slaves serial data output line, it is possible for several slaves to receive the same transmission from a master, although the master would not receive return information from all of the receiving slaves. if the cpha bit in spi control register 1 is clear, odd numbered edges on the sck input cause the data at the serial data input pin to be latched. even numbered edges cause the value previously latched from the serial data input pin to shift into the lsb or msb of the spi shift register, depending on the lsbfe bit. if the cpha bit is set, even numbered edges on the sck input cause the data at the serial data input pin to be latched. odd numbered edges cause the value previously latched from the serial data input pin to shift into the lsb or msb of the spi shift register, depending on the lsbfe bit. when cpha is set, the ?st edge is used to get the ?st data bit onto the serial data output pin. when cpha is clear and the ss input is low (slave selected), the ?st bit of the spi data is driven out of the serial data output pin. after the eighth shift, the transfer is considered complete and the received data is transferred into the spi data register. to indicate transfer is complete, the spif ?g in the spi status register is set. note a change of the bits cpol, cpha, ssoe, lsbfe, modfen, spc0 and bidiroe with spc0 set in slave mode will corrupt a transmission in progress and has to be avoided.
chapter 14 serial peripheral interface (spiv3) block description 422 mc9s12q128 freescale semiconductor rev 1.09 14.4.3 transmission formats during an spi transmission, data is transmitted (shifted out serially) and received (shifted in serially) simultaneously. the serial clock (sck) synchronizes shifting and sampling of the information on the two serial data lines. a slave select line allows selection of an individual slave spi device, slave devices that are not selected do not interfere with spi bus activities. optionally, on a master spi device, the slave select line can be used to indicate multiple-master bus contention. figure 14-8. master/slave transfer block diagram 14.4.3.1 clock phase and polarity controls using two bits in the spi control register1, software selects one of four combinations of serial clock phase and polarity. the cpol clock polarity control bit speci?s an active high or low clock and has no signi?ant effect on the transmission format. the cpha clock phase control bit selects one of two fundamentally different transmission formats. clock phase and polarity should be identical for the master spi device and the communicating slave device. in some cases, the phase and polarity are changed between transmissions to allow a master device to communicate with peripheral slaves having different requirements. 14.4.3.2 cpha = 0 transfer format the ?st edge on the sck line is used to clock the ?st data bit of the slave into the master and the ?st data bit of the master into the slave. in some peripherals, the ?st bit of the slaves data is available at the slaves data out pin as soon as the slave is selected. in this format, the ?st sck edge is issued a half cycle after ss has become low. a half sck cycle later, the second edge appears on the sck line. when this second edge occurs, the value previously latched from the serial data input pin is shifted into the lsb or msb of the shift register, depending on lsbfe bit. after this second edge, the next bit of the spi master data is transmitted out of the serial data output pin of the master to the serial input pin on the slave. this process continues for a total of 16 edges on the sck line, with data being latched on odd numbered edges and shifted on even numbered edges. shift register shift register baud rate generator master spi slave spi mosi mosi miso miso sck sck ss ss v dd
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 423 rev 1.09 data reception is double buffered. data is shifted serially into the spi shift register during the transfer and is transferred to the parallel spi data register after the last bit is shifted in. after the 16th (last) sck edge: data that was previously in the master spi data register should now be in the slave data register and the data that was in the slave data register should be in the master. the spif ?g in the spi status register is set indicating that the transfer is complete. figure 14-9 is a timing diagram of an spi transfer where cpha = 0. sck waveforms are shown for cpol = 0 and cpol = 1. the diagram may be interpreted as a master or slave timing diagram because the sck, miso, and mosi pins are connected directly between the master and the slave. the miso signal is the output from the slave and the mosi signal is the output from the master. the ss pin of the master must be either high or recon?ured as a general-purpose output not affecting the spi. figure 14-9. spi clock format 0 (cpha = 0) in slave mode, if the ss line is not deasserted between the successive transmissions then the content of the spi data register is not transmitted, instead the last received byte is transmitted. if the ss line is deasserted for at least minimum idle time (half sck cycle) between successive transmissions then the content of the spi data register is transmitted. tl begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0): lsb ?st (lsbfe = 1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) mosi pin miso pin master only mosi/miso tt if next transfer begins here for t t , t l , t l minimum 1/2 sck ti tl t l = minimum leading time before the ?st sck edge t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time) t l , t t , and t i are guaranteed for the master mode and required for the slave mode. 1 2 34 56 78910111213141516 sck edge nr. end of idle state begin of idle state
chapter 14 serial peripheral interface (spiv3) block description 424 mc9s12q128 freescale semiconductor rev 1.09 in master mode, with slave select output enabled the ss line is always deasserted and reasserted between successive transfers for at least minimum idle time. 14.4.3.3 cpha = 1 transfer format some peripherals require the ?st sck edge before the ?st data bit becomes available at the data out pin, the second edge clocks data into the system. in this format, the ?st sck edge is issued by setting the cpha bit at the beginning of the 8-cycle transfer operation. the ?st edge of sck occurs immediately after the half sck clock cycle synchronization delay. this ?st edge commands the slave to transfer its ?st data bit to the serial data input pin of the master. a half sck cycle later, the second edge appears on the sck pin. this is the latching edge for both the master and slave. when the third edge occurs, the value previously latched from the serial data input pin is shifted into the lsb or msb of the spi shift register, depending on lsbfe bit. after this edge, the next bit of the master data is coupled out of the serial data output pin of the master to the serial input pin on the slave. this process continues for a total of 16 edges on the sck line with data being latched on even numbered edges and shifting taking place on odd numbered edges. data reception is double buffered, data is serially shifted into the spi shift register during the transfer and is transferred to the parallel spi data register after the last bit is shifted in. after the 16th sck edge: data that was previously in the spi data register of the master is now in the data register of the slave, and data that was in the data register of the slave is in the master. the spif ?g bit in spisr is set indicating that the transfer is complete. figure 14-10 shows two clocking variations for cpha = 1. the diagram may be interpreted as a master or slave timing diagram because the sck, miso, and mosi pins are connected directly between the master and the slave. the miso signal is the output from the slave, and the mosi signal is the output from the master. the ss line is the slave select input to the slave. the ss pin of the master must be either high or recon?ured as a general-purpose output not affecting the spi. the ss line can remain active low between successive transfers (can be tied low at all times). this format is sometimes preferred in systems having a single ?ed master and a single slave that drive the miso data line. back-to-back transfers in master mode in master mode, if a transmission has completed and a new data byte is available in the spi data register, this byte is send out immediately without a trailing and minimum idle time. the spi interrupt request ?g (spif) is common to both the master and slave modes. spif gets set one half sck cycle after the last sck edge.
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 425 rev 1.09 figure 14-10. spi clock format 1 (cpha = 1) 14.4.4 spi baud rate generation baud rate generation consists of a series of divider stages. six bits in the spi baud rate register (sppr2, sppr1, sppr0, spr2, spr1, and spr0) determine the divisor to the spi module clock which results in the spi baud rate. the spi clock rate is determined by the product of the value in the baud rate preselection bits (sppr2?ppr0) and the value in the baud rate selection bits (spr2?pr0). the module clock divisor equation is shown in figure 14-11 when all bits are clear (the default condition), the spi module clock is divided by 2. when the selection bits (spr2?pr0) are 001 and the preselection bits (sppr2?ppr0) are 000, the module clock divisor becomes 4. when the selection bits are 010, the module clock divisor becomes 8 etc. when the preselection bits are 001, the divisor determined by the selection bits is multiplied by 2. when the preselection bits are 010, the divisor is multiplied by 3, etc. see table 14-7 for baud rate calculations for all bit conditions, based on a 25-mhz bus clock. the two sets of selects allows the clock to be divided by a non-power of two to achieve other baud rates such as divide by 6, divide by 10, etc. tl tt for t t , t l , t l minimum 1/2 sck ti tl if next transfer begins here begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0): lsb ?st (lsbfe = 1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) mosi pin miso pin master only mosi/miso t l = minimum leading time before the ?st sck edge, not required for back to back transfers t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time), not required for back to back transfers 1 2 34 56 78910111213141516 sck edge nr. end of idle state begin of idle state
chapter 14 serial peripheral interface (spiv3) block description 426 mc9s12q128 freescale semiconductor rev 1.09 the baud rate generator is activated only when the spi is in the master mode and a serial transfer is taking place. in the other cases, the divider is disabled to decrease i dd current. figure 14-11. baud rate divisor equation 14.4.5 special features 14.4.5.1 ss output the ss output feature automatically drives the ss pin low during transmission to select external devices and drives it high during idle to deselect external devices. when ss output is selected, the ss output pin is connected to the ss input pin of the external device. the ss output is available only in master mode during normal spi operation by asserting ssoe and modfen bit as shown in table 14-3 . the mode fault feature is disabled while ss output is enabled. note care must be taken when using the ss output feature in a multimaster system because the mode fault feature is not available for detecting system errors between masters. 14.4.5.2 bidirectional mode (mosi or miso) the bidirectional mode is selected when the spc0 bit is set in spi control register 2 (see table 14-9 ). in this mode, the spi uses only one serial data pin for the interface with external device(s). the mstr bit decides which pin to use. the mosi pin becomes the serial data i/o (momi) pin for the master mode, and the miso pin becomes serial data i/o (siso) pin for the slave mode. the miso pin in master mode and mosi pin in slave mode are not used by the spi. table 14-9. normal mode and bidirectional mode when spe = 1 master mode mstr = 1 slave mode mstr = 0 normal mode spc0 = 0 bidirectional mode spc0 = 1 baudratedivisor sppr 1 + () 2 ? spr 1 + () = spi mosi miso serial out serial in spi mosi miso serial in serial out spi momi serial out serial in bidiroe spi siso serial in serial out bidiroe
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 427 rev 1.09 the direction of each serial i/o pin depends on the bidiroe bit. if the pin is con?ured as an output, serial data from the shift register is driven out on the pin. the same pin is also the serial input to the shift register. the sck is output for the master mode and input for the slave mode. the ss is the input or output for the master mode, and it is always the input for the slave mode. the bidirectional mode does not affect sck and ss functions. note in bidirectional master mode, with mode fault enabled, both data pins miso and mosi can be occupied by the spi, though mosi is normally used for transmissions in bidirectional mode and miso is not used by the spi. if a mode fault occurs, the spi is automatically switched to slave mode, in this case miso becomes occupied by the spi and mosi is not used. this has to be considered, if the miso pin is used for other purpose. 14.4.6 error conditions the spi has one error condition: mode fault error 14.4.6.1 mode fault error if the ss input becomes low while the spi is con?ured as a master, it indicates a system error where more than one master may be trying to drive the mosi and sck lines simultaneously. this condition is not permitted in normal operation, the modf bit in the spi status register is set automatically provided the modfen bit is set. in the special case where the spi is in master mode and modfen bit is cleared, the ss pin is not used by the spi. in this special case, the mode fault error function is inhibited and modf remains cleared. in case the spi system is con?ured as a slave, the ss pin is a dedicated input pin. mode fault error doesnt occur in slave mode. if a mode fault error occurs the spi is switched to slave mode, with the exception that the slave output buffer is disabled. so sck, miso and mosi pins are forced to be high impedance inputs to avoid any possibility of con?ct with another output driver. a transmission in progress is aborted and the spi is forced into idle state. if the mode fault error occurs in the bidirectional mode for a spi system con?ured in master mode, output enable of the momi (mosi in bidirectional mode) is cleared if it was set. no mode fault error occurs in the bidirectional mode for spi system con?ured in slave mode. the mode fault ?g is cleared automatically by a read of the spi status register (with modf set) followed by a write to spi control register 1. if the mode fault ?g is cleared, the spi becomes a normal master or slave again.
chapter 14 serial peripheral interface (spiv3) block description 428 mc9s12q128 freescale semiconductor rev 1.09 14.4.7 operation in run mode in run mode with the spi system enable (spe) bit in the spi control register clear, the spi system is in a low-power, disabled state. spi registers remain accessible, but clocks to the core of this module are disabled. 14.4.8 operation in wait mode spi operation in wait mode depends upon the state of the spiswai bit in spi control register 2. if spiswai is clear, the spi operates normally when the cpu is in wait mode if spiswai is set, spi clock generation ceases and the spi module enters a power conservation state when the cpu is in wait mode. if spiswai is set and the spi is con?ured for master, any transmission and reception in progress stops at wait mode entry. the transmission and reception resumes when the spi exits wait mode. if spiswai is set and the spi is con?ured as a slave, any transmission and reception in progress continues if the sck continues to be driven from the master. this keeps the slave synchronized to the master and the sck. if the master transmits several bytes while the slave is in wait mode, the slave will continue to send out bytes consistent with the operation mode at the start of wait mode (i.e. if the slave is currently sending its spidr to the master, it will continue to send the same byte. else if the slave is currently sending the last received byte from the master, it will continue to send each previous master byte). note care must be taken when expecting data from a master while the slave is in wait or stop mode. even though the shift register will continue to operate, the rest of the spi is shut down (i.e. a spif interrupt will not be generated until exiting stop or wait mode). also, the byte from the shift register will not be copied into the spidr register until after the slave spi has exited wait or stop mode. a spif ?g and spidr copy is only generated if wait mode is entered or exited during a tranmission. if the slave enters wait mode in idle mode and exits wait mode in idle mode, neither a spif nor a spidr copy will occur. 14.4.9 operation in stop mode stop mode is dependent on the system. the spi enters stop mode when the module clock is disabled (held high or low). if the spi is in master mode and exchanging data when the cpu enters stop mode, the transmission is frozen until the cpu exits stop mode. after stop, data to and from the external spi is exchanged correctly. in slave mode, the spi will stay synchronized with the master. the stop mode is not dependent on the spiswai bit.
chapter 14 serial peripheral interface (spiv3) block description freescale semiconductor mc9s12q128 429 rev 1.09 14.5 reset the reset values of registers and signals are described in the memory map and registers section (see section 14.3, ?emory map and register de?ition ) which details the registers and their bit-?lds. if a data transmission occurs in slave mode after reset without a write to spidr, it will transmit garbage, or the byte last received from the master before the reset. reading from the spidr after reset will always read a byte of zeros. 14.6 interrupts the spiv3 only originates interrupt requests when spi is enabled (spe bit in spicr1 set). the following is a description of how the spiv3 makes a request and how the mcu should acknowledge that request. the interrupt vector offset and interrupt priority are chip dependent. the interrupt ?gs modf, spif and sptef are logically ored to generate an interrupt request. 14.6.1 modf modf occurs when the master detects an error on the ss pin. the master spi must be con?ured for the modf feature (see table 14-3 ). after modf is set, the current transfer is aborted and the following bit is changed: mstr = 0, the master bit in spicr1 resets. the modf interrupt is re?cted in the status register modf ?g. clearing the ?g will also clear the interrupt. this interrupt will stay active while the modf ?g is set. modf has an automatic clearing process which is described in section 14.3.2.4, ?pi status register (spisr) . 14.6.2 spif spif occurs when new data has been received and copied to the spi data register. after spif is set, it does not clear until it is serviced. spif has an automatic clearing process which is described in section 14.3.2.4, ?pi status register (spisr) . in the event that the spif is not serviced before the end of the next transfer (i.e. spif remains active throughout another transfer), the latter transfers will be ignored and no new data will be copied into the spidr. 14.6.3 sptef sptef occurs when the spi data register is ready to accept new data. after sptef is set, it does not clear until it is serviced. sptef has an automatic clearing process which is described in section 14.3.2.4, ?pi status register (spisr) .
chapter 14 serial peripheral interface (spiv3) block description 430 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 431 rev 1.09 chapter 15 timer module (tim16b6c) block description 15.1 introduction the basic timer consists of a 16-bit, software-programmable counter driven by a seven-stage programmable prescaler. this timer can be used for many purposes, including input waveform measurements while simultaneously generating an output waveform. pulse widths can vary from microseconds to many seconds. this timer contains 6 complete input capture/output compare channels and one pulse accumulator. the input capture function is used to detect a selected transition edge and record the time. the output compare function is used for generating output signals or for timer software delays. the 16-bit pulse accumulator is used to operate as a simple event counter or a gated time accumulator. the pulse accumulator shares timer channel 7 when in event mode. a full access for the counter registers or the input capture/output compare registers should take place in one clock cycle. accessing high byte and low byte separately for all of these registers may not yield the same result as accessing them in one word. 15.1.1 features the tim16b6c includes these distinctive features: six input capture/output compare channels. clock prescaling. 16-bit counter. 16-bit pulse accumulator. 15.1.2 modes of operation stop: timer is off because clocks are stopped. freeze: timer counter keep on running, unless tsfrz in tscr (0x0006) is set to 1. wait: counters keep on running, unless tswai in tscr (0x0006) is set to 1. normal: timer counter keep on running, unless ten in tscr (0x0006) is cleared to 0.
chapter 15 timer module (tim16b6c) block description 432 mc9s12q128 freescale semiconductor rev 1.09 15.1.3 block diagrams figure 15-1. tim16b6c block diagram prescaler 16-bit counter 16-bit pulse accumulator ioc2 ioc5 ioc3 ioc4 ioc6 ioc7 pa input interrupt pa overflow interrupt timer overflow interrupt timer channel 2 interrupt timer channel 7 interrupt registers bus clock input capture output compare input capture output compare input capture output compare input capture output compare input capture output compare input capture output compare channel 2 channel 3 channel 4 channel 5 channel 6 channel 7
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 433 rev 1.09 figure 15-2. 16-bit pulse accumulator block diagram figure 15-3. interrupt flag setting figure 15-4. channel 7 output compare/pulse accumulator logic note for more information see the respective functional descriptions in section 15.4, ?unctional description , of this document. edge detector intermodule bus pt7 m clock divide by 64 clock select clk0 clk1 4:1 mux timclk (timer clock) paclk paclk / 256 paclk / 65536 prescaled clock (pclk) interrupt mux (pamod) pacnt ptn edge detector 16-bit main timer tcn input capture reg. set cnf interrupt pulse accumulator pad om7 ol7 oc7m7 channel 7 output compare
chapter 15 timer module (tim16b6c) block description 434 mc9s12q128 freescale semiconductor rev 1.09 15.2 external signal description the tim16b6c module has a total of eight external pins. 15.2.1 ioc7 ?input capture and output compare channel 7 pin this pin serves as input capture or output compare for channel 7. this can also be con?ured as pulse accumulator input. 15.2.2 ioc6 ?input capture and output compare channel 6 pin this pin serves as input capture or output compare for channel 6. 15.2.3 ioc5 ?input capture and output compare channel 5 pin this pin serves as input capture or output compare for channel 5. 15.2.4 ioc4 ?input capture and output compare channel 4 pin this pin serves as input capture or output compare for channel 4. pin 15.2.5 ioc3 ?input capture and output compare channel 3 pin this pin serves as input capture or output compare for channel 3. 15.2.6 ioc2 ?input capture and output compare channel 2 pin this pin serves as input capture or output compare for channel 2. note for the description of interrupts see section 15.6, ?nterrupts . 15.3 memory map and registers this section provides a detailed description of all memory and registers. 15.3.1 module memory map the following paragraphs describe the content of the registers in the tim16b6c module. the memory map for the tim16b6c module is given below in figure 15-5 . the address listed for each register is the address offset. the total address for each register is the sum of the base address for the tim16b6c module and the address offset for each register.
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 435 rev 1.09 15.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. address name bit 7 654321 bit 0 0x0000 tios r ios7 ios6 ios5 ios4 ios3 ios2 w 0x0001 cforc r00000000 w foc7 foc6 foc5 foc4 foc3 foc2 0x0002 oc7m r oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 w 0x0003 oc7d r oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 w 0x0004 tcnth r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w 0x0005 tcntl r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w 0x0006 tscr1 r ten tswai tsfrz tffca 0000 w 0x0007 ttov r tov7 tov6 tov5 tov4 tov3 tov2 w 0x0008 tctl1 r om7 ol7 om6 ol6 om5 ol5 om4 ol4 w 0x0009 tctl2 r om3 ol3 om2 ol2 w 0x000a tctl3 r edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a w 0x000b tctl4 r edg3b edg3a edg2b edg2a w 0x000c tie r c7i c6i c5i c4i c3i c2i c1i c0i w 0x000d tscr2 r toi 000 tcre pr2 pr1 pr0 w 0x000e tflg1 r c7f c6f c5f c4f c3f c2f w 0x000f tflg2 r tof 0000000 w = unimplemented or reserved figure 15-5. tim16b6c register summary
chapter 15 timer module (tim16b6c) block description 436 mc9s12q128 freescale semiconductor rev 1.09 15.3.2.1 timer input capture/output compare select (tios) read: anytime write: anytime 0x0010 0x0013 reserved r w 0x0014 0x001f tcxh tcxl r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0020 pactl r0 paen pamod pedge clk1 clk0 paovi pai w 0x0021 paflg r000000 paovf paif w 0x0022 pacnth r pacnt15 pacnt14 pacnt13 pacnt12 pacnt11 pacnt10 pacnt9 pacnt8 w 0x0023 pacntl r pacnt7 pacnt6 pacnt5 pacnt4 pacnt3 pacnt2 pacnt1 pacnt0 w 0x0024 0x002f reserved r w module base + 0x0000 76543210 r ios7 ios6 ios5 ios4 ios3 ios2 w reset 0 0 0 00000 figure 15-6. timer input capture/output compare select (tios) table 15-1. tios field descriptions field description 7:2 ios[7:2] input capture or output compare channel con?uration 0 the corresponding channel acts as an input capture. 1 the corresponding channel acts as an output compare. address name bit 7 654321 bit 0 = unimplemented or reserved figure 15-5. tim16b6c register summary (continued)
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 437 rev 1.09 15.3.2.2 timer compare force register (cforc) read: anytime but will always return 0x0000 (1 state is transient) write: anytime 15.3.2.3 output compare 7 mask register (oc7m) read: anytime write: anytime module base + 0x0001 76543210 r00000000 w foc7 foc6 foc5 foc4 foc3 foc2 reset 0 0 0 00000 figure 15-7. timer compare force register (cforc) table 15-2. cforc field descriptions field description 7:2 foc[7:2] force output compare action for channel 7:2 a write to this register with the corresponding data bit(s) set causes the action which is programmed for output compare ??to occur immediately. the action taken is the same as if a successful comparison had just taken place with the tcx register except the interrupt ?g does not get set. note: a successful channel 7 output compare overrides any channel 6:2 compares. if forced output compare on any channel occurs at the same time as the successful output compare then forced output compare action will take precedence and interrupt ?g won? get set. module base + 0x0002 76543210 r oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 w reset 0 0 0 00000 figure 15-8. output compare 7 mask register (oc7m) table 15-3. oc7m field descriptions field description 7:2 oc7m[7:2] output compare 7 mask setting the oc7mx (x ranges from 2 to 6) will set the corresponding port to be an output port when the corresponding tiosx (x ranges from 2 to 6) bit is set to be an output compare. note: a successful channel 7 output compare overrides any channel 6:2 compares. for each oc7m bit that is set, the output compare action re?cts the corresponding oc7d bit.
chapter 15 timer module (tim16b6c) block description 438 mc9s12q128 freescale semiconductor rev 1.09 15.3.2.4 output compare 7 data register (oc7d) read: anytime write: anytime 15.3.2.5 timer count register (tcnt) the 16-bit main timer is an up counter. a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read: anytime write: has no meaning or effect in the normal mode; only writable in special modes (test_mode = 1). the period of the ?st count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. module base + 0x0003 76543210 r oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 w reset 0 0 0 00000 figure 15-9. output compare 7 data register (oc7d) table 15-4. oc7d field descriptions field description 7:2 oc7d[7:2] output compare 7 data ?a channel 7 output compare can cause bits in the output compare 7 data register to transfer to the timer port data register depending on the output compare 7 mask register. module base + 0x0004 15 14 13 12 11 10 9 9 r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w reset 0 0 0 00000 figure 15-10. timer count register high (tcnth) module base + 0x0005 76543210 r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w reset 0 0 0 00000 figure 15-11. timer count register low (tcntl)
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 439 rev 1.09 15.3.2.6 timer system control register 1 (tscr1) read: anytime write: anytime module base + 0x0006 76543210 r ten tswai tsfrz tffca 0000 w reset 0 0 0 00000 = unimplemented or reserved figure 15-12. timer system control register 1 (tscr1) table 15-5. tscr1 field descriptions field description 7 ten timer enable 0 disables the main timer, including the counter. can be used for reducing power consumption. 1 allows the timer to function normally. if for any reason the timer is not active, there is no 64 clock for the pulse accumulator because the 64 is generated by the timer prescaler. 6 tswai timer module stops while in wait 0 allows the timer module to continue running during wait. 1 disables the timer module when the mcu is in the wait mode. timer interrupts cannot be used to get the mcu out of wait. tswai also affects pulse accumulator. 5 tsfrz timer stops while in freeze mode 0 allows the timer counter to continue running while in freeze mode. 1 disables the timer counter whenever the mcu is in freeze mode. this is useful for emulation. tsfrz does not stop the pulse accumulator. 4 tffca timer fast flag clear all 0 allows the timer ?g clearing to function normally. 1 for tflg1(0x000e), a read from an input capture or a write to the output compare channel (0x0010?x001f) causes the corresponding channel ?g, cnf, to be cleared. for tflg2 (0x000f), any access to the tcnt register (0x0004, 0x0005) clears the tof ?g. any access to the pacnt registers (0x0022, 0x0023) clears the paovf and paif ?gs in the paflg register (0x0021). this has the advantage of eliminating software overhead in a separate clear sequence. extra care is required to avoid accidental ?g clearing due to unintended accesses.
chapter 15 timer module (tim16b6c) block description 440 mc9s12q128 freescale semiconductor rev 1.09 15.3.2.7 timer toggle on over?w register 1 (ttov) read: anytime write: anytime 15.3.2.8 timer control register 1/timer control register 2 (tctl1/tctl2) read: anytime write: anytime module base + 0x0007 76543210 r tov7 tov6 tov5 tov4 tov3 tov2 w reset 0 0 0 00000 figure 15-13. timer toggle on over?w register 1 (ttov) table 15-6. ttov field descriptions field description 7:2 tov[7:2] toggle on over?w bits tovx toggles output compare pin on over?w. this feature only takes effect when in output compare mode. when set, it takes precedence over forced output compare but not channel 7 override events. 0 toggle output compare pin on over?w feature disabled. 1 toggle output compare pin on over?w feature enabled. module base + 0x0008 76543210 r om7 ol7 om6 ol6 om5 ol5 om4 ol4 w reset 0 0 0 00000 figure 15-14. timer control register 1 (tctl1) module base + 0x0009 76543210 r om3 ol3 om2 ol2 w reset 0 0 0 00000 figure 15-15. timer control register 2 (tctl2)
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 441 rev 1.09 to operate the 16-bit pulse accumulator independently of input capture or output compare 7 and 0 respectively the user must set the corresponding bits iosx = 1, omx = 0 and olx = 0. oc7m7 in the oc7m register must also be cleared. table 15-7. tctl1/tctl2 field descriptions field description 7:2 omx output mode ?these control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: to enable output action by omx bits on timer port, the corresponding bit in oc7m should be cleared. 7:2 olx output level ?these control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: to enable output action by olx bits on timer port, the corresponding bit in oc7m should be cleared. table 15-8. compare result output action omx olx action 0 0 timer disconnected from output pin logic 0 1 toggle ocx output line 1 0 clear ocx output line to zero 1 1 set ocx output line to one
chapter 15 timer module (tim16b6c) block description 442 mc9s12q128 freescale semiconductor rev 1.09 15.3.2.9 timer control register 3/timer control register 4 (tctl3 and tctl4) read: anytime write: anytime. module base + 0x000a 76543210 r edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a w reset 0 0 0 00000 figure 15-16. timer control register 3 (tctl3) module base + 0x000b 76543210 r edg3b edg3a edg2b edg2a w reset 0 0 0 00000 figure 15-17. timer control register 4 (tctl4) table 15-9. tctl3/tctl4 field descriptions field description 7:0 edgnb edgna input capture edge control these six pairs of control bits con?ure the input capture edge detector circuits. table 15-10. edge detector circuit con?uration edgnb edgna con?uration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only 1 1 capture on any edge (rising or falling)
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 443 rev 1.09 15.3.2.10 timer interrupt enable register (tie) read: anytime write: anytime. caution user software must ensure that c1i and c0i remain clear. module base + 0x000c 76543210 r c7i c6i c5i c4i c3i c2i c1i c0i w reset 0 0 0 00000 figure 15-18. timer interrupt enable register (tie) table 15-11. tie field descriptions field description 7:0 c7i:c0i input capture/output compare ??interrupt enable the bits in tie correspond bit-for-bit with the bits in the tflg1 status register. if cleared, the corresponding ?g is disabled from causing a hardware interrupt. if set, the corresponding ?g is enabled to cause a interrupt.
chapter 15 timer module (tim16b6c) block description 444 mc9s12q128 freescale semiconductor rev 1.09 15.3.2.11 timer system control register 2 (tscr2) read: anytime write: anytime. note the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal zero. module base + 0x000d 76543210 r toi 000 tcre pr2 pr1 pr0 w reset 0 0 0 00000 = unimplemented or reserved figure 15-19. timer system control register 2 (tscr2) table 15-12. tscr2 field descriptions field description 7 toi timer over?w interrupt enable 0 interrupt inhibited. 1 hardware interrupt requested when tof ?g set. 3 tcre timer counter reset enable this bit allows the timer counter to be reset by a successful output compare 7 event. this mode of operation is similar to an up-counting modulus counter. 0 counter reset inhibited and counter free runs. 1 counter reset by a successful output compare 7. if tc7 = 0x0000 and tcre = 1, tcnt will stay at 0x0000 continuously. if tc7 = 0xffff and tcre = 1, tof will never be set when tcnt is reset from 0xffff to 0x0000. 2 pr[2:0] timer prescaler select ?these three bits select the frequency of the timer prescaler clock derived from the bus clock as shown in table 15-13 . table 15-13. timer clock selection pr2 pr1 pr0 timer clock 0 0 0 bus clock / 1 0 0 1 bus clock / 2 0 1 0 bus clock / 4 0 1 1 bus clock / 8 1 0 0 bus clock / 16 1 0 1 bus clock / 32 1 1 0 bus clock / 64 1 1 1 bus clock / 128
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 445 rev 1.09 15.3.2.12 main timer interrupt flag 1 (tflg1) read: anytime write: used in the clearing mechanism (set bits cause corresponding bits to be cleared). writing a zero will not affect current status of the bit. 15.3.2.13 main timer interrupt flag 2 (tflg2) tflg2 indicates when interrupt conditions have occurred. to clear a bit in the ?g register, write the bit to one. read: anytime write: used in clearing mechanism (set bits cause corresponding bits to be cleared). any access to tcnt will clear tflg2 register if the tffca bit in tscr register is set. module base + 0x000e 76543210 r c7f c6f c5f c4f c3f c2f w reset 0 0 0 00000 figure 15-20. main timer interrupt flag 1 (tflg1) table 15-14. trlg1 field descriptions field description 7:2 c[7:2]f input capture/output compare channel ??flag ?these flags are set when an input capture or output compare event occurs. clear a channel ?g by writing one to it. when tffca bit in tscr register is set, a read from an input capture or a write into an output compare channel (0x0010?x001f) will cause the corresponding channel ?g cxf to be cleared. module base + 0x000f 76543210 r tof 0000000 w reset 0 0 0 00000 unimplemented or reserved figure 15-21. main timer interrupt flag 2 (tflg2) table 15-15. trlg2 field descriptions field description 7 tof timer over?w flag set when 16-bit free-running timer over?ws from 0xffff to 0x0000. this bit is cleared automatically by a write to the tflg2 register with bit 7 set. (see also tcre control bit explanation.)
chapter 15 timer module (tim16b6c) block description 446 mc9s12q128 freescale semiconductor rev 1.09 15.3.2.14 timer input capture/output compare registers high and low 2? (tcxh and tcxl) depending on the tios bit for the corresponding channel, these registers are used to latch the value of the free-running counter when a de?ed transition is sensed by the corresponding input capture edge detector or to trigger an output action for output compare. read: anytime write: anytime for output compare function.writes to these registers have no meaning or effect during input capture. all timer input capture/output compare registers are reset to 0x0000. note read/write access in byte mode for high byte should takes place before low byte otherwise it will give a different result. module base + 0x0014 = tc2h 0x0016 = tc3h 0x0018 = tc4h 0x001a = tc5h 0x001c = tc6h 0x001e = tc7h 15 14 13 12 11 10 9 0 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 0 0 000000 figure 15-22. timer input capture/output compare register x high (tcxh) module base + 0x0015 = tc2l 0x0017 = tc3l 0x0019 = tc4l 0x001b = tc5l 0x001d = tc6l 0x001f = tc7l 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 00000000 figure 15-23. timer input capture/output compare register x low (tcxl)
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 447 rev 1.09 15.3.2.15 16-bit pulse accumulator control register (pactl) when paen is set, the pact is enabled.the pact shares the input pin with ioc7. read: any time write: any time module base + 0x0020 76543210 r0 paen pamod pedge clk1 clk0 paovi pai w reset 0 0 0 00000 unimplemented or reserved figure 15-24. 16-bit pulse accumulator control register (pactl) table 15-16. pactl field descriptions field description 6 paen pulse accumulator system enable ?paen is independent from ten. with timer disabled, the pulse accumulator can function unless pulse accumulator is disabled. 0 16-bit pulse accumulator system disabled. 1 pulse accumulator system enabled. 5 pamod pulse accumulator mode ?this bit is active only when the pulse accumulator is enabled (paen = 1). see table 15-17 . 0 event counter mode. 1 gated time accumulation mode. 4 pedge pulse accumulator edge control this bit is active only when the pulse accumulator is enabled (paen = 1). for pamod bit = 0 (event counter mode). see table 15-17 . 0 falling edges on ioc7 pin cause the count to be incremented. 1 rising edges on ioc7 pin cause the count to be incremented. for pamod bit = 1 (gated time accumulation mode). 0 ioc7 input pin high enables m (bus clock) divided by 64 clock to pulse accumulator and the trailing falling edge on ioc7 sets the paif ?g. 1 ioc7 input pin low enables m (bus clock) divided by 64 clock to pulse accumulator and the trailing rising edge on ioc7 sets the paif ?g. 3:2 clk[1:0] clock select bits refer to table 15-18 . 1 paov i pulse accumulator over?w interrupt enable 0 interrupt inhibited. 1 interrupt requested if paovf is set. 0 pa i pulse accumulator input interrupt enable 0 interrupt inhibited. 1 interrupt requested if paif is set.
chapter 15 timer module (tim16b6c) block description 448 mc9s12q128 freescale semiconductor rev 1.09 note if the timer is not active (ten = 0 in tscr), there is no divide-by-64 because the 64 clock is generated by the timer prescaler. for the description of paclk please refer figure 15-24 . if the pulse accumulator is disabled (paen = 0), the prescaler clock from the timer is always used as an input clock to the timer counter. the change from one selected clock to the other happens immediately after these bits are written. table 15-17. pin action pamod pedge pin action 0 0 falling edge 0 1 rising edge 1 0 div. by 64 clock enabled with pin high level 1 1 div. by 64 clock enabled with pin low level table 15-18. timer clock selection clk1 clk0 timer clock 0 0 use timer prescaler clock as timer counter clock 0 1 use paclk as input to timer counter clock 1 0 use paclk/256 as timer counter clock frequency 1 1 use paclk/65536 as timer counter clock frequency
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 449 rev 1.09 15.3.2.16 pulse accumulator flag register (paflg) read: anytime write: anytime when the tffca bit in the tscr register is set, any access to the pacnt register will clear all the ?gs in the paflg register. module base + 0x0021 76543210 r000000 paovf paif w reset 0 0 0 00000 unimplemented or reserved figure 15-25. pulse accumulator flag register (paflg) table 15-19. paflg field descriptions field description 1 paov f pulse accumulator over?w flag set when the 16-bit pulse accumulator over?ws from 0xffff to 0x0000. this bit is cleared automatically by a write to the paflg register with bit 1 set. 0 paif pulse accumulator input edge flag set when the selected edge is detected at the ioc7 input pin.in event mode the event edge triggers paif and in gated time accumulation mode the trailing edge of the gate signal at the ioc7 input pin triggers paif. this bit is cleared by a write to the paflg register with bit 0 set. any access to the pacnt register will clear all the ?gs in this register when tffca bit in register tscr(0x0006) is set.
chapter 15 timer module (tim16b6c) block description 450 mc9s12q128 freescale semiconductor rev 1.09 15.3.2.17 pulse accumulators count registers (pacnt) read: anytime write: anytime these registers contain the number of active input edges on its input pin since the last reset. when pacnt over?ws from 0xffff to 0x0000, the interrupt ?g paovf in paflg (0x0021) is set. full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. note reading the pulse accumulator counter registers immediately after an active edge on the pulse accumulator input pin may miss the last count because the input has to be synchronized with the bus clock ?st. module base + 0x0022 15 14 13 12 11 10 9 0 r pacnt15 pacnt14 pacnt13 pacnt12 pacnt11 pacnt10 pacnt9 pacnt8 w reset 0 0 0 00000 figure 15-26. pulse accumulator count register high (pacnth) module base + 0x0023 76543210 r pacnt7 pacnt6 pacnt5 pacnt4 pacnt3 pacnt2 pacnt1 pacnt0 w reset 0 0 0 00000 figure 15-27. pulse accumulator count register low (pacntl)
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 451 rev 1.09 15.4 functional description this section provides a complete functional description of the timer tim16b6c block. please refer to the detailed timer block diagram in figure 15-28 as necessary. figure 15-28. detailed timer block diagram prescaler channel 2 ioc2 pin 16-bit counter logic pr[2:1:0] divide-by-64 tc2 edge detect pacnt(hi):pacnt(lo) paovf pedge paovi pamod pae 16-bit comparator tcnt(hi):tcnt(lo) channel 3 tc3 16-bit comparator 16-bit counter interrupt logic tof toi c2f c3f edge detect ioc3 pin logic edge detect cxf channel7 tc7 16-bit comparator c7f ioc7 pin logic edge detect om:ol2 tov2 om:ol2 tov2 om:o73 tov7 edg1a edg1b edg7a edg7b edg0b tcre paif clear counter paif pai interrupt logic cxi interrupt request paovf ch. 7 compare ch.7 capture ch. 3 capture mux clk[1:0] paclk paclk/256 paclk/65536 ioc3 pin ioc2 pin ioc7 pin paclk paclk/256 paclk/65536 te ch. 3 compare ch. 2compare ch. 2capture pa input channel4 edg0a channel 7 output compare ioc2 ioc3 ioc7 bus clock bus clock paovf paovi tof c2f c3f c7f
chapter 15 timer module (tim16b6c) block description 452 mc9s12q128 freescale semiconductor rev 1.09 15.4.1 prescaler the prescaler divides the bus clock by 1, 2, 4, 8, 16, 32, 64, or 128. the prescaler select bits, pr[2:0], select the prescaler divisor. pr[2:0] are in timer system control register 2 (tscr2). 15.4.2 input capture clearing the i/o (input/output) select bit, iosx, con?ures channel x as an input capture channel. the input capture function captures the time at which an external event occurs. when an active edge occurs on the pin of an input capture channel, the timer transfers the value in the timer counter into the timer channel registers, tcx. the minimum pulse width for the input capture input is greater than two bus clocks. an input capture on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. 15.4.3 output compare setting the i/o select bit, iosx, con?ures channel x as an output compare channel. the output compare function can generate a periodic pulse with a programmable polarity, duration, and frequency. when the timer counter reaches the value in the channel registers of an output compare channel, the timer can set, clear, or toggle the channel pin. an output compare on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. the output mode and level bits, omx and olx, select set, clear, toggle on output compare. clearing both omx and olx disconnects the pin from the output logic. setting a force output compare bit, focx, causes an output compare on channel x. a forced output compare does not set the channel ?g. a successful output compare on channel 7 overrides output compares on all other output compare channels. the output compare 7 mask register masks the bits in the output compare 7 data register. the timer counter reset enable bit, tcre, enables channel 7 output compares to reset the timer counter. a channel 7 output compare can reset the timer counter even if the ioc7 pin is being used as the pulse accumulator input. writing to the timer port bit of an output compare pin does not affect the pin state. the value written is stored in an internal latch. when the pin becomes available for general-purpose output, the last value written to the bit appears at the pin. 15.4.4 pulse accumulator the pulse accumulator (pacnt) is a 16-bit counter that can operate in two modes: event counter mode ?counting edges of selected polarity on the pulse accumulator input pin, pai. gated time accumulation mode counting pulses from a divide-by-64 clock. the pamod bit selects the mode of operation. the minimum pulse width for the pai input is greater than two bus clocks.
chapter 15 timer module (tim16b6c) block description freescale semiconductor mc9s12q128 453 rev 1.09 15.4.5 event counter mode clearing the pamod bit con?ures the pacnt for event counter operation. an active edge on the ioc7 pin increments the pulse accumulator counter. the pedge bit selects falling edges or rising edges to increment the count. note the pacnt input and timer channel 7 use the same pin ioc7. to use the ioc7, disconnect it from the output logic by clearing the channel 7 output mode and output level bits, om7 and ol7. also clear the channel 7 output compare 7 mask bit, oc7m7. the pulse accumulator counter register re?ct the number of active input edges on the pacnt input pin since the last reset. the paovf bit is set when the accumulator rolls over from 0xffff to 0x0000. the pulse accumulator over?w interrupt enable bit, paovi, enables the paovf ?g to generate interrupt requests. note the pulse accumulator counter can operate in event counter mode even when the timer enable bit, ten, is clear. 15.4.6 gated time accumulation mode setting the pamod bit con?ures the pulse accumulator for gated time accumulation operation. an active level on the pacnt input pin enables a divided-by-64 clock to drive the pulse accumulator. the pedge bit selects low levels or high levels to enable the divided-by-64 clock. the trailing edge of the active level at the ioc7 pin sets the paif. the pai bit enables the paif ?g to generate interrupt requests. the pulse accumulator counter register re?ct the number of pulses from the divided-by-64 clock since the last reset. note the timer prescaler generates the divided-by-64 clock. if the timer is not active, there is no divided-by-64 clock. 15.5 resets the reset state of each individual bit is listed within section 15.3, ?emory map and registers which details the registers and their bit ?lds.
chapter 15 timer module (tim16b6c) block description 454 mc9s12q128 freescale semiconductor rev 1.09 15.6 interrupts this section describes interrupts originated by the tim16b6c block. table 15-20 lists the interrupts generated by the tim16b6c to communicate with the mcu. the tim16b6c uses a total of 9 interrupt vectors. the interrupt vector offsets and interrupt numbers are chip dependent. 15.6.1 channel [7:2] interrupt (c[7:2]f) this active high outputs will be asserted by the module to request a timer channel 7? interrupt to be serviced by the system controller. caution user software must ensure that c1i and c0i remain clear. 15.6.2 pulse accumulator input interrupt (paovi) this active high output will be asserted by the module to request a timer pulse accumulator input interrupt to be serviced by the system controller. 15.6.3 pulse accumulator over?w interrupt (paovf) this active high output will be asserted by the module to request a timer pulse accumulator over?w interrupt to be serviced by the system controller. 15.6.4 timer over?w interrupt (tof) this active high output will be asserted by the module to request a timer over?w interrupt to be serviced by the system controller. table 15-20. tim16b8cv1 interrupts interrupt offset (1) 1. chip dependent. vector 1 priority 1 source description c[7:2]f timer channel 7? active high timer channel interrupts 7? paovi pulse accumulator input active high pulse accumulator input interrupt paovf pulse accumulator over?w pulse accumulator over?w interrupt tof timer over?w timer over?w interrupt
freescale semiconductor mc9s12q128 455 rev 1.09 chapter 16 dual output voltage regulator (vreg3v3v2) block description 16.1 introduction the vreg3v3v2 is a dual output voltage regulator providing two separate 2.5 v (typical) supplies differing in the amount of current that can be sourced. the regulator input voltage range is from 3.3 v up to 5 v (typical). 16.1.1 features the block vreg3v3v2 includes these distinctive features: two parallel, linear voltage regulators bandgap reference low-voltage detect (lvd) with low-voltage interrupt (lvi) power-on reset (por) low-voltage reset (lvr) 16.1.2 modes of operation there are three modes vreg3v3v2 can operate in: full-performance mode (fpm) (mcu is not in stop mode) the regulator is active, providing the nominal supply voltage of 2.5 v with full current sourcing capability at both outputs. features lvd (low-voltage detect), lvr (low-voltage reset), and por (power-on reset) are available. reduced-power mode (rpm) (mcu is in stop mode) the purpose is to reduce power consumption of the device. the output voltage may degrade to a lower value than in full-performance mode, additionally the current sourcing capability is substantially reduced. only the por is available in this mode, lvd and lvr are disabled. shutdown mode controlled by v regen (see device overview chapter for connectivity of v regen ). this mode is characterized by minimum power consumption. the regulator outputs are in a high impedance state, only the por feature is available, lvd and lvr are disabled. this mode must be used to disable the chip internal regulator vreg3v3v2, i.e., to bypass the vreg3v3v2 to use external supplies.
chapter 16 dual output voltage regulator (vreg3v3v2) block description 456 mc9s12q128 freescale semiconductor rev 1.09 16.1.3 block diagram figure 16-1 shows the function principle of vreg3v3v2 by means of a block diagram. the regulator core reg consists of two parallel sub-blocks, reg1 and reg2, providing two independent output voltages. figure 16-1. vreg3v3 block diagram lv r lv d por v ddr v dd lvi por lvr ctrl v ss v ddpll v sspll v regen reg reg2 reg1 pin v dda v ssa reg: regulator core lvd: low voltage detect ctrl: regulator control lvr: low voltage reset por: power-on reset
chapter 16 dual output voltage regulator (vreg3v3v2) block description freescale semiconductor mc9s12q128 457 rev 1.09 16.2 external signal description due to the nature of vreg3v3v2 being a voltage regulator providing the chip internal power supply voltages most signals are power supply signals connected to pads. table 16-1 shows all signals of vreg3v3v2 associated with pins. note check device overview chapter for connectivity of the signals. 16.2.1 v ddr ?regulator power input signal v ddr is the power input of vreg3v3v2. all currents sourced into the regulator loads flow through this pin. a chip external decoupling capacitor (100 nf...220 nf, x7r ceramic) between v ddr and v ssr can smoothen ripple on v ddr . for entering shutdown mode, pin v ddr should also be tied to ground on devices without a v regen pin. 16.2.2 v dda , v ssa ?regulator reference supply signals v dda /v ssa which are supposed to be relatively quiet are used to supply the analog parts of the regulator. internal precision reference circuits are supplied from these signals. a chip external decoupling capacitor (100 nf...220 nf, x7r ceramic) between v dda and v ssa can further improve the quality of this supply. table 16-1. vreg3v3v2 ?signal properties name port function reset state pull up v ddr vreg3v3v2 power input (positive supply) v dda vreg3v3v2 quiet input (positive supply) v ssa vreg3v3v2 quiet input (ground) v dd vreg3v3v2 primary output (positive supply) v ss vreg3v3v2 primary output (ground) v ddpll vreg3v3v2 secondary output (positive supply) v sspll vreg3v3v2 secondary output (ground) v regen (optional) vreg3v3v2 (optional) regulator enable
chapter 16 dual output voltage regulator (vreg3v3v2) block description 458 mc9s12q128 freescale semiconductor rev 1.09 16.2.3 v dd , v ss ?regulator output1 (core logic) signals v dd /v ss are the primary outputs of vreg3v3v2 that provide the power supply for the core logic. these signals are connected to device pins to allow external decoupling capacitors (100 nf...220 nf, x7r ceramic). in shutdown mode an external supply at v dd /v ss can replace the voltage regulator. 16.2.4 v ddpll , v sspll ?regulator output2 (pll) signals v ddpll /v sspll are the secondary outputs of vreg3v3v2 that provide the power supply for the pll and oscillator. these signals are connected to device pins to allow external decoupling capacitors (100 nf...220 nf, x7r ceramic). in shutdown mode an external supply at v ddpll /v sspll can replace the voltage regulator. 16.2.5 v regen ?optional regulator enable this optional signal is used to shutdown vreg3v3v2. in that case v dd /v ss and v ddpll /v sspll must be provided externally. shutdown mode is entered with v regen being low. if v regen is high, the vreg3v3v2 is either in full performance mode or in reduced power mode. for the connectivity of v regen see device overview chapter. note switching from fpm or rpm to shutdown of vreg3v3v2 and vice versa is not supported while the mcu is powered. 16.3 memory map and register de?ition this subsection provides a detailed description of all registers accessible in vreg3v3v2. 16.3.1 module memory map figure 16-2 provides an overview of all used registers. table 16-2. vreg3v3v2 memory map address offset use access 0x0000 vreg3v3v2 control register (vregctrl) r/w
chapter 16 dual output voltage regulator (vreg3v3v2) block description freescale semiconductor mc9s12q128 459 rev 1.09 16.3.2 register descriptions the following paragraphs describe, in address order, all the vreg3v3v2 registers and their individual bits. 16.3.2.1 vreg3v3v2 ?control register (vregctrl) the vregctrl register allows to separately enable features of vreg3v3v2. note on entering the reduced power mode the lvif is not cleared by the vreg3v3v2. 16.4 functional description block vreg3v3v2 is a voltage regulator as depicted in figure 16-1 . the regulator functional elements are the regulator core (reg), a low-voltage detect module (lvd), a power-on reset module (por) and a low-voltage reset module (lvr). there is also the regulator control block (ctrl) which represents the interface to the digital core logic but also manages the operating modes of vreg3v3v2. module base + 0x0000 76543210 r00000lvds lvie lvif w reset 0 0 0 00000 = unimplemented or reserved figure 16-2. vreg3v3 ?control register (vregctrl) table 16-3. mcctl1 field descriptions field description 2 lvds low-voltage detect status bit ?this read-only status bit re?cts the input voltage. writes have no effect. 0 input voltage v dda is above level v lvid or rpm or shutdown mode. 1 input voltage v dda is below level v lvia and fpm. 1 lvie low-voltage interrupt enable bit 0 interrupt request is disabled. 1 interrupt will be requested whenever lvif is set. 0 lvif low-voltage interrupt flag lvif is set to 1 when lvds status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (lvie = 1), lvif causes an interrupt request. 0 no change in lvds bit. 1 lvds bit has changed.
chapter 16 dual output voltage regulator (vreg3v3v2) block description 460 mc9s12q128 freescale semiconductor rev 1.09 16.4.1 reg ?regulator core vreg3v3v2, respectively its regulator core has two parallel, independent regulation loops (reg1 and reg2) that differ only in the amount of current that can be sourced to the connected loads. therefore, only reg1 providing the supply at v dd /v ss is explained. the principle is also valid for reg2. the regulator is a linear series regulator with a bandgap reference in its full performance mode and a voltage clamp in reduced power mode. all load currents flow from input v ddr to v ss or v sspll , the reference circuits are connected to v dda and v ssa . 16.4.2 full-performance mode in full performance mode, a fraction of the output voltage (v dd ) and the bandgap reference voltage are fed to an operational amplifier. the amplified input voltage difference controls the gate of an output driver which basically is a large nmos transistor connected to the output. 16.4.3 reduced-power mode in reduced power mode, the driver gate is connected to a buffered fraction of the input voltage (v ddr ). the operational amplifier and the bandgap are disabled to reduce power consumption. 16.4.4 lvd ?low-voltage detect sub-block lvd is responsible for generating the low-voltage interrupt (lvi). lvd monitors the input voltage (v dda ? ssa ) and continuously updates the status flag lvds. interrupt flag lvif is set whenever status flag lvds changes its value. the lvd is available in fpm and is inactive in reduced power mode and shutdown mode. 16.4.5 por ?power-on reset this functional block monitors output v dd . if v dd is below v pord , signal por is high, if it exceeds v pord , the signal goes low. the transition to low forces the cpu in the power-on sequence. due to its role during chip power-up this module must be active in all operating modes of vreg3v3v2. 16.4.6 lvr ?low-voltage reset block lvr monitors the primary output voltage v dd . if it drops below the assertion level (v lvra ) signal lvr asserts and when rising above the deassertion level (v lvrd ) signal lvr negates again. the lvr function is available only in full performance mode. 16.4.7 ctrl ?regulator control this part contains the register block of vreg3v3v2 and further digital functionality needed to control the operating modes. ctrl also represents the interface to the digital core logic.
chapter 16 dual output voltage regulator (vreg3v3v2) block description freescale semiconductor mc9s12q128 461 rev 1.09 16.5 resets this subsection describes how vreg3v3v2 controls the reset of the mcu.the reset values of registers and signals are provided in section 16.3, ?emory map and register definition . possible reset sources are listed in table 16-4 . 16.5.1 power-on reset during chip power-up the digital core may not work if its supply voltage v dd is below the por deassertion level (v pord ). therefore, signal por which forces the other blocks of the device into reset is kept high until v dd exceeds v pord . then por becomes low and the reset generator of the device continues the start-up sequence. the power-on reset is active in all operation modes of vreg3v3v2. 16.5.2 low-voltage reset for details on low-voltage reset see section 16.4.6, ?vr ?low-voltage reset . 16.6 interrupts this subsection describes all interrupts originated by vreg3v3v2. the interrupt vectors requested by vreg3v3v2 are listed in table 16-5 . vector addresses and interrupt priorities are defined at mcu level. 16.6.1 lvi ?low-voltage interrupt in fpm vreg3v3v2 monitors the input voltage v dda . whenever v dda drops below level v lvia the status bit lvds is set to 1. vice versa, lvds is reset to 0 when v dda rises above level v lvid . an interrupt, indicated by flag lvif = 1, is triggered by any change of the status bit lvds if interrupt enable bit lvie = 1. note on entering the reduced power mode, the lvif is not cleared by the vreg3v3v2. table 16-4. vreg3v3v2 ?reset sources reset source local enable power-on reset always active low-voltage reset available only in full performance mode table 16-5. vreg3v3v2 ?interrupt vectors interrupt source local enable low voltage interrupt (lvi) lvie = 1; available only in full performance mode
chapter 16 dual output voltage regulator (vreg3v3v2) block description 462 mc9s12q128 freescale semiconductor rev 1.09
freescale semiconductor mc9s12q128 463 rev 1.09 chapter 17 32 kbyte flash module (s12fts32kv1) 17.1 introduction the fts32k module implements a 32 kbyte flash (nonvolatile) memory. the flash memory contains one array of 32 kbytes organized as 512 rows of 64 bytes with an erase sector size of eight rows ( 512 bytes). the flash array may be read as either bytes, aligned words, or misaligned words. read access time is one bus cycle for byte and aligned word, and two bus cycles for misaligned words. the flash array is ideal for program and data storage for single-supply applications allowing for ?ld reprogramming without requiring external voltage sources for program or erase. program and erase functions are controlled by a command driven interface. the flash module supports both mass erase and sector erase. an erased bit reads 1 and a programmed bit reads 0. the high voltage required to program and erase is generated internally. it is not possible to read from a flash array while it is being erased or programmed. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. 17.1.1 glossary command write sequence a three-step mcu instruction sequence to program, erase, or erase verify the flash array memory. 17.1.2 features 32 kbytes of flash memory comprised of one 32 kbyte array divided into 64 sectors of 512 bytes automated program and erase algorithm interrupts on flash command completion and command buffer empty fast sector erase and word program operation 2-stage command pipeline for faster multi-word program times flexible protection scheme to prevent accidental program or erase single power supply for flash program and erase operations security feature to prevent unauthorized access to the flash array memory
chapter 17 32 kbyte flash module (s12fts32kv1) 464 mc9s12q128 freescale semiconductor rev 1.09 17.1.3 modes of operation see section 17.4.2, ?perating modes ?for a description of the flash module operating modes. for program and erase operations, refer to section 17.4.1, ?lash command operations . 17.1.4 block diagram figure 17-1 shows a block diagram of the fts32k module. figure 17-1. fts32k block diagram 17.2 external signal description the fts32k module contains no signals that connect off-chip. fts32k oscillator clock command complete interrupt command buffer empty interrupt flash array 16k * 16 bits sector 0 sector 1 sector 63 clock divider fclk protection security command pipeline cmd2 addr2 data2 cmd1 addr1 data1 registers flash interface
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 465 rev 1.09 17.3 memory map and registers this section describes the fts32k memory map and registers. 17.3.1 module memory map the fts32k memory map is shown in figure 17-2 . the hcs12 architecture places the flash array addresses between 0x4000 and 0xffff , which corresponds to three 16 kbyte pages . the content of the hcs12 core ppage register is used to map the logical middle page ranging from address 0x8000 to 0xbfff to a ny physical 16k byte page in the flash array memory. 1 the fprot register (see section 17.3.2.5 ) can be set to globally protect the entire flash array . three separate areas, one starting from the flash array starting address (called lower) towards higher addresses, one growing downward from the flash array end address (called higher), and the remaining addresses, can be activated for protection . the flash array addresses covered by these protectable regions are shown in figure 17-2. the higher address area is mainly targeted to hold the boot loader code since it covers the vector space. the lower address area can be used for eeprom emulation in an mcu without an eeprom module since it can be left unprotected while the remaining addresses are protected from program or erase. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld described in table 17-1 . 1. by placing 0x3e/ 0x3f in the hcs12 core ppage register, the bottom/top ?ed 16 kbyte page s can be seen twice in the mcu memory map. table 17-1. flash con?uration field flash address size (bytes) description 0xff00?xff07 8 backdoor key to unlock security 0xff08?xff0c 5 reserved 0xff0d 1 flash protection byte refer to section 17.3.2.5, ?lash protection register (fprot) 0xff0e 1 reserved 0xff0f 1 flash security/options byte refer to section 17.3.2.2, ?lash security register (fsec)
chapter 17 32 kbyte flash module (s12fts32kv1) 466 mc9s12q128 freescale semiconductor rev 1.09 figure 17-2. flash memory map flash registers module base + 0x0000 0xff00?xff0f (flash con?uration field) module base + 0x000f 0x8000 flash protected low sectors 512 bytes, 1, 2, 4 kbytes flash_start = 0x4000 0x4800 0x4200 0x5000 16k paged memory 0x3e 003e 0x3f note: 0x3e?x3f correspond to the ppage register content flash_end = 0xffff 0xf800 0xf000 0xc000 0xe000 flash protected high sectors 2, 4, 8, 16 kbytes 0x3f 0x4400 flash array 16 bytes
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 467 rev 1.09 table 17-2. flash array memory map summary mcu address range ppage protectable low range protectable high range array relative address (1) 1. inside flash block. 0x4000?x7fff unpaged (0x3e) 0x4000?x43ff n.a. 0x18000?x1bfff 0x4000?x47ff 0x4000?x4fff 0x4000?x5fff 0x8000?xbfff 0x3e 0x8000?x83ff n.a. 0x18000?x1bfff 0x8000?x87ff 0x8000?x8fff 0x8000?x9fff 0x3f n.a. 0xb800?xbfff 0x1c000?x1ffff 0xb000?xbfff 0xa000?xbfff 0x8000?xbfff 0xc000?xffff unpaged (0x3f) n.a. 0xf800?xffff 0x1c000?x1ffff 0xf000?xffff 0xe000?xffff 0xc000?xffff
chapter 17 32 kbyte flash module (s12fts32kv1) 468 mc9s12q128 freescale semiconductor rev 1.09 17.3.2 register descriptions the flash module contains a set of 16 control and status registers located between module base + 0x0000 and 0x000f. a summary of the flash module registers is given in figure 17-3 . detailed descriptions of each register bit are provided. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 fclkdiv r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w 0x0002 reserved1 (1) 1. intended for factory test purposes only. r00000000 w 0x0003 fcnfg r cbeie ccie keyacc 00000 w 0x0004 fprot r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0005 fstat r cbeif ccif pviol accerr 0 blank fail done w 0x0006 fcmd r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w 0x0007 reserved2 1 r00000000 w 0x0008 faddrhi 1 r 0 0 fabhi w 0x0009 faddrlo 1 r fablo w 0x000a fdatahi 1 r fdhi w 0x000b fdatalo 1 r fdlo w 0x000c reserved3 1 r00000000 w 0x000d reserved4 1 r00000000 w 0x000e reserved5 1 r00000000 w 0x000f reserved6 1 r00000000 w = unimplemented or reserved figure 17-3. flash register summary
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 469 rev 1.09 17.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bits 6? are write once and bit 7 is not writable. 17.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. the fsec register is loaded from the flash con?uration ?ld at 0xff0f during the reset sequence, indicated by f in figure 17-5 . module base + 0x0000 76543210 r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w reset 00000000 = unimplemented or reserved figure 17-4. flash clock divider register (fclkdiv) table 17-3. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written 1 fclkdiv register has been written to since the last reset 6 prdiv8 enable prescalar by 8 0 the oscillator clock is directly fed into the flash clock divider 1 the oscillator clock is divided by 8 before feeding into the flash clock divider 5? fdiv[5:0] clock divider bits ?the combination of prdiv8 and fdiv[5:0] must divide the oscillator clock down to a frequency of 150 khz ?200 khz. the maximum divide ratio is 512. refer to section 17.4.1.1, ?riting the fclkdiv register for more information. module base + 0x0001 76543210 r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w reset f f ffffff = unimplemented or reserved figure 17-5. flash security register (fsec)
chapter 17 32 kbyte flash module (s12fts32kv1) 470 mc9s12q128 freescale semiconductor rev 1.09 the security function in the flash module is described in section 17.4.3, ?lash module security . 17.3.2.3 reserved1 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. table 17-4. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits ?the keyen[1:0] bits de?e the enabling of the backdoor key access to the flash module as shown in table 17-5 . 5? nv[5:2] nonvolatile flag bits ?the nv[5:2] bits are available to the user as nonvolatile ?gs. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 17-6 . if the flash module is unsecured using backdoor key access, the sec[1:0] bits are forced to 1:0. table 17-5. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 (1) 1. preferred keyen state to disable backdoor key access. disabled 10 enabled 11 disabled table 17-6. flash security states sec[1:0] status of security 00 secured 01 (1) 1. preferred sec state to set mcu to secured state. secured 10 unsecured 11 secured module base + 0x0002 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 17-6. reserved1
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 471 rev 1.09 17.3.2.4 flash con?uration register (fcnfg) the fcnfg register enables the flash interrupts and gates the security backdoor key writes. cbeie, ccie, and keyacc are readable and writable while remaining bits read 0 and are not writable. keyacc is only writable if the keyen bit in the fsec register is set to the enabled state (see section 17.3.2.2 ). 17.3.2.5 flash protection register (fprot) the fprot register de?es which flash sectors are protected against program or erase. the fprot register is readable in normal and special modes. fpopen can only be written from a 1 to a 0. fpls[1:0] can be written anytime until fpldis is cleared. fphs[1:0] can be written anytime until module base + 0x0003 76543210 r cbeie ccie keyacc 00000 w reset 00000000 = unimplemented or reserved figure 17-7. flash con?uration register (fcnfg) table 17-7. fcnfg field descriptions field description 7 cbeie command buffer empty interrupt enable ?the cbeie bit enables the interrupts in case of an empty command buffer in the flash module. 0 command buffer empty interrupts disabled 1 an interrupt will be requested whenever the cbeif ?g is set (see section 17.3.2.6 ) 6 ccie command complete interrupt enable ?the ccie bit enables the interrupts in case of all commands being completed in the flash module. 0 command complete interrupts disabled 1 an interrupt will be requested whenever the ccif ?g is set (see section 17.3.2.6 ) 5 keyacc enable security key writing . 0 flash writes are interpreted as the start of a command write sequence 1 writes to the flash array are interpreted as a backdoor key while reads of the flash array return invalid data module base + 0x0004 76543210 r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w reset f f ffffff figure 17-8. flash protection register (fprot)
chapter 17 32 kbyte flash module (s12fts32kv1) 472 mc9s12q128 freescale semiconductor rev 1.09 fphdis is cleared. the fprot register is loaded from flash address 0xff0d during the reset sequence, indicated by f in figure 17-8 . to change the flash protection that will be loaded on reset, the upper sector of the flash array must be unprotected, then the flash protection byte located at flash address 0xff0d must be written to. a protected flash sector is disabled by fphdis and fpldis while the size of the protected sector is de?ed by fphs[1:0] and fpls[1:0] in the fprot register. trying to alter any of the protected areas will result in a protect violation error and the pviol ?g will be set in the fstat register (see section 17.3.2.6 ). a mass erase of the whole flash array is only possible when protection is fully disabled by setting the fpopen , fpldis, and fphdis bits. an attempt to mass erase a flash array while protection is enabled will set the pviol ?g in the fstat register. table 17-8. fprot field descriptions field description 7 fpopen protection function for program or erase ?it is possible using the fpopen bit to either select address ranges to be protected using fphdis, fpldis, fphs[1:0] and fpls[1:0] or to select the same ranges to be unprotected. when fpopen is set, fpxdis enables the ranges to be protected, whereby clearing fpxdis enables protection for the range speci?d by the corresponding fpxs[1:0] bits. when fpopen is cleared, fpxdis de?es unprotected ranges as speci?d by the corresponding fpxs[1:0] bits. in this case, setting fpxdis enables protection. thus the effective polarity of the fpxdis bits is swapped by the fpopen bit as shown in table 17-9 . this function allows the main part of the flash array to be protected while a small range can remain unprotected for eeprom emulation. 0 the fphdis and fpldis bits de?e flash address ranges to be unprotected 1 the fphdis and fpldis bits de?e flash address ranges to be protected 6 nv6 nonvolatile flag bit ?the nv6 bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in the higher space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs[1:0] bits determine the size of the protected/unprotected sector as shown in table 17-10 . the fphs[1:0] bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected sector in the lower space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls[1:0] bits determine the size of the protected/unprotected sector as shown in table 17-11 . the fpls[1:0] bits can only be written to while the fpldis bit is set.
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 473 rev 1.09 figure 17-9 illustrates all possible protection scenarios. although the protection scheme is loaded from the flash array after reset, it is allowed to change in normal modes. this protection scheme can be used by applications requiring re-programming in single chip mode while providing as much protection as possible if no re-programming is required. table 17-9. flash protection function fpopen fphdis fphs[1] fphs[0] fpldis fpls[1] fpls[0] function (1) 1. for range sizes refer to table 17-10 and or table 17-11 . 1 1 x x 1 x x no protection 1 1 x x 0 x x protect low range 1 0 x x 1 x x protect high range 1 0 x x 0 x x protect high and low ranges 0 1 x x 1 x x full flash array protected 0 0 x x 1 x x unprotected high range 0 1 x x 0 x x unprotected low range 0 0 x x 0 x x unprotected high and low ranges table 17-10. flash protection higher address range fphs[1:0] address range range size 00 0xf800?xffff 2 kbytes 01 0xf000?xffff 4 kbytes 10 0xe000?xffff 8 kbytes 11 0xc000?xffff 16 kbytes table 17-11. flash protection lower address range fpls[1:0] address range range size 00 0x4000?x41ff 512 bytes 01 0x4000?x43ff 1 kbyte 10 0x4000?x47ff 2 kbytes 11 0x4000?x4fff 4 kbytes
chapter 17 32 kbyte flash module (s12fts32kv1) 474 mc9s12q128 freescale semiconductor rev 1.09 figure 17-9. flash protection scenarios 17.3.2.5.1 flash protection restrictions the general guideline is that protection can only be added, not removed. all valid transitions between flash protection scenarios are speci?d in table 17-12 . any attempt to write an invalid scenario to the fprot register will be ignored and the fprot register will remain unchanged. the contents of the fprot register re?ct the active protection scenario. table 17-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567 0 xxxx 1xx 2xx 3x 4xx 5 xxxx 7 6 5 4 fpopen = 1 3 2 1 0 fphs[1:0] fpls[1:0] fpopen = 0 fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario protected flash fphs[1:0] fpls[1:0] 0xffff 0xffff
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 475 rev 1.09 17.3.2.6 flash status register (fstat) the fstat register de?es the status of the flash command controller and the results of command execution. in normal modes, bits cbeif, pviol, and accerr are readable and writable, bits ccif and blank are readable and not writable, remaining bits, including fail and done, read 0 and are not writable. in special modes, fail is readable and writable while done is readable but not writable. fail must be clear in special modes when starting a command write sequence. 6xxxx 7 xxxxxxxx 1. allowed transitions marked with x. module base + 0x0005 76543210 r cbeif ccif pviol accerr 0 blank fail done w reset 11000001 = unimplemented or reserved figure 17-10. flash status register (fstat) table 17-13. fstat field descriptions field description 7 cbeif command buffer empty interrupt flag ?the cbeif ?g indicates that the address, data and command buffers are empty so that a new command write sequence can be started. the cbeif ?g is cleared by writing a 1 to cbeif. writing a 0 to the cbeif ?g has no effect on cbeif. writing a 0 to cbeif after writing an aligned word to the flash address space but before cbeif is cleared will abort a command write sequence and cause the accerr ?g in the fstat register to be set. writing a 0 to cbeif outside of a command write sequence will not set the accerr ?g. the cbeif ?g is used together with the cbeie bit in the fcnfg register to generate an interrupt request (see figure 17-26 ). 0 buffers are full 1 buffers are ready to accept a new command 6 ccif command complete interrupt flag the ccif ?g indicates that there are no more commands pending. the ccif ?g is cleared when cbeif is clear and sets automatically upon completion of all active and pending commands. the ccif ?g does not set when an active commands completes and a pending command is fetched from the command buffer. writing to the ccif ?g has no effect. the ccif ?g is used together with the ccie bit in the fcnfg register to generate an interrupt request (see figure 17-26 ). 0 command in progress 1 all commands are completed table 17-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567
chapter 17 32 kbyte flash module (s12fts32kv1) 476 mc9s12q128 freescale semiconductor rev 1.09 17.3.2.7 flash command register (fcmd) the fcmd register de?es the flash commands. bits cmdb6, cmdb5, cmdb2, and cmdb0 are readable and writable during a command write sequence while bits 7, 4, 3, and 1 read 0 and are not writable. 5 pviol protection violation ?the pviol ?g indicates an attempt was made to program or erase an address in a protected flash array memory area. the pviol ?g is cleared by writing a 1 to pviol. writing a 0 to the pviol ?g has no effect on pviol. while pviol is set, it is not possible to launch another command. 0 no protection violation detected 1 protection violation has occurred 4 accerr access error the accerr ?g indicates an illegal access to the flash array caused by either a violation of the command write sequence, issuing an illegal command (illegal combination of the cmdbx bits in the fcmd register) or the execution of a cpu stop instruction while a command is executing (ccif=0). the accerr ?g is cleared by writing a 1 to accerr. writing a 0 to the accerr ?g has no effect on accerr. while accerr is set, it is not possible to launch another command. 0 no access error detected 1 access error has occurred 2 blank flash array has been veri?d as erased ?the blank ?g indicates that an erase verify command has checked the flash array and found it to be erased. the blank ?g is cleared by hardware when cbeif is cleared as part of a new valid command write sequence. writing to the blank ?g has no effect on blank. 0 if an erase verify command has been requested, and the ccif ?g is set, then a 0 in blank indicates the array is not erased 1 flash array veri?s as erased 1 fail flag indicating a failed flash operation in special modes, the fail ?g will set if the erase verify operation fails (flash array veri?d as not erased). writing a 0 to the fail ?g has no effect on fail. the fail ?g is cleared by writing a 1 to fail. while fail is set, it is not possible to launch another command. 0 flash operation completed without error 1 flash operation failed 0 done flag indicating a failed operation is not active ?in special modes, the done ?g will clear if a program, erase, or erase verify operation is active. 0 flash operation is active 1 flash operation is not active module base + 0x0006 76543210 r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w reset 00000000 = unimplemented or reserved figure 17-11. flash command register (fcmd) table 17-13. fstat field descriptions field description
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 477 rev 1.09 17.3.2.8 reserved2 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 17.3.2.9 flash address register (faddr) faddrhi and faddrlo are the flash address registers. \ table 17-14. fcmd field descriptions field description 6, 5, 2, 0 cmdb[6:5] cmdb[2] cmdb[0] valid flash commands are shown in table 17-15 . an attempt to execute any command other than those listed in table 17-15 will set the accerr bit in the fstat register (see section 17.3.2.6 ). table 17-15. valid flash command list cmdb nvm command 0x05 erase verify 0x20 word program 0x40 sector erase 0x41 mass erase module base + 0x0007 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 17-12. reserved2 module base + 0x0008 76543210 r0 0 fabhi w reset 00000000 = unimplemented or reserved figure 17-13. flash address high register (faddrhi)
chapter 17 32 kbyte flash module (s12fts32kv1) 478 mc9s12q128 freescale semiconductor rev 1.09 in normal modes, all fabhi and fablo bits read 0 and are not writable. in special modes, the fabhi and fablo bits are readable and writable. for sector erase, the mcu address bits [8:0] are ignored .for mass erase, any address within the flash array is valid to start the command. 17.3.2.10 flash data register (fdata) fdatahi and fdatalo are the flash data registers. in normal modes, all fdatahi and fdatalo bits read 0 and are not writable. in special modes, all fdatahi and fdatalo bits are readable and writable when writing to an address within the flash address range. 17.3.2.11 reserved3 this register is reserved for factory testing and is not accessible to the user. module base + 0x0009 76543210 r fablo w reset 00000000 figure 17-14. flash address low register (faddrlo) module base + 0x000a 76543210 r fdhi w reset 00000000 figure 17-15. flash data high register (fdatahi) module base + 0x000b 76543210 r fdlo w reset 00000000 figure 17-16. flash data low register (fdatalo)
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 479 rev 1.09 all bits read 0 and are not writable. 17.3.2.12 reserved4 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 17.3.2.13 reserved5 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 17.3.2.14 reserved6 this register is reserved for factory testing and is not accessible to the user. module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 17-17. reserved3 module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 17-18. reserved4 module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 17-19. reserved5
chapter 17 32 kbyte flash module (s12fts32kv1) 480 mc9s12q128 freescale semiconductor rev 1.09 all bits read 0 and are not writable. 17.4 functional description 17.4.1 flash command operations write operations are used for the program, erase, and erase verify algorithms described in this section. the program and erase algorithms are controlled by a state machine whose timebase fclk is derived from the oscillator clock via a programmable divider. the fcmd register as well as the associated faddr and fdata registers operate as a buffer and a register (2-stage fifo) so that a new command along with the necessary data and address can be stored to the buffer while the previous command is still in progress. this pipelined operation allows a time optimization when programming more than one word on a speci? row, as the high voltage generation can be kept active in between two programming commands. the pipelined operation also allows a simpli?ation of command launching. buffer empty as well as command completion are signalled by ?gs in the fstat register with corresponding interrupts generated, if enabled. the next sections describe: how to write the fclkdiv register command write sequence used to program, erase or erase verify the flash array valid flash commands errors resulting from illegal flash operations 17.4.1.1 writing the fclkdiv register prior to issuing any flash command after a reset, it is ?st necessary to write the fclkdiv register to divide the oscillator clock down to within the 150-khz to 200-khz range. since the program and erase timings are also a function of the bus clock, the fclkdiv determination must take this information into account. if we de?e: fclk as the clock of the flash timing control block tbus as the period of the bus clock int(x) as taking the integer part of x (e.g., int(4.323) = 4), module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 17-20. reserved6
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 481 rev 1.09 then fclkdiv register bits prdiv8 and fdiv[5:0] are to be set as described in figure 17-21 . for example, if the oscillator clock frequency is 950 khz and the bus clock is 10 mhz, fclkdiv bits fdiv[5:0] should be set to 4 (000100) and bit prdiv8 set to 0. the resulting fclk is then 190 khz. as a result, the flash algorithm timings are increased over optimum target by: command execution time will increase proportionally with the period of fclk. caution because of the impact of clock synchronization on the accuracy of the functional timings, programming or erasing the flash array cannot be performed if the bus clock runs at less than 1 mhz. programming or erasing the flash array with an input clock < 150 khz should be avoided. setting fclkdiv to a value such that fclk < 150 khz can destroy the flash array due to overstress. setting fclkdiv to a value such that (1/fclk + tbus) < 5 s can result in incomplete programming or erasure of the flash array cells. if the fclkdiv register is written, the bit fdivld is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written to, the flash command loaded during a command write sequence will not execute and the accerr ?g in the fstat register will set. 200 190 () 200 ? 100 5% =
chapter 17 32 kbyte flash module (s12fts32kv1) 482 mc9s12q128 freescale semiconductor rev 1.09 figure 17-21. prdiv8 and fdiv bits determination procedure prdiv8=1 yes no prdiv8=0 (reset) 12.8mhz? fclk=(prdclk)/(1+fdiv[5:0]) prdclk=oscillator_clock prdclk=oscillator_clock/8 prdclk[mhz]*(5+tbus[ms]) no fdiv[5:0]=prdclk[mhz]*(5+tbus[ms])-1 yes start tbus < 1ms? an integer? fdiv[5:0]=int(prdclk[mhz]*(5+tbus[ms])) 1/fclk[mhz] + tbus[ms] > 5 and fclk > 0.15mhz ? end yes no fdiv[5:0] > 4? all commands impossible yes no all commands impossible no try to decrease tbus yes oscillator_clock
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 483 rev 1.09 17.4.1.2 command write sequence the flash command controller is used to supervise the command write sequence to execute program, erase, and erase verify algorithms. before starting a command write sequence, the accerr and pviol ?gs in the fstat register must be clear and the cbeif ?g should be tested to determine the state of the address, data, and command buffers. if the cbeif ?g is set, indicating the buffers are empty, a new command write sequence can be started. if the cbeif ?g is clear, indicating the buffers are not available, a new command write sequence will overwrite the contents of the address, data, and command buffers. a command write sequence consists of three steps which must be strictly adhered to with writes to the flash module not permitted between the steps. however, flash register and array reads are allowed during a command write sequence. the basic command write sequence is as follows: 1. write to a valid address in the flash array memory. 2. write a valid command to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the command. the address written in step 1 will be stored in the faddr registers and the data will be stored in the fdata registers. when the cbeif ?g is cleared in step 3, the ccif ?g is cleared by the flash command controller indicating that the command was successfully launched. for all command write sequences, the cbeif ?g will set after the ccif ?g is cleared indicating that the address, data, and command buffers are ready for a new command write sequence to begin. a buffered command will wait for the active operation to be completed before being launched. once a command is launched, the completion of the command operation is indicated by the setting of the ccif ?g in the fstat register. the ccif ?g will set upon completion of all active and buffered commands.
chapter 17 32 kbyte flash module (s12fts32kv1) 484 mc9s12q128 freescale semiconductor rev 1.09 17.4.1.3 valid flash commands table 17-16 summarizes the valid flash commands along with the effects of the commands on the flash array. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. table 17-16. valid flash commands fcmd meaning function on flash array 0x05 erase verify verify all bytes in the flash array are erased. if the flash array is erased, the blank bit will set in the fstat register upon command completion. 0x20 program program a word (2 bytes) in the flash array. 0x40 sector erase erase all 512 bytes in a sector of the flash array. 0x41 mass erase erase all bytes in the flash array. a mass erase of the full flash array is only possible when fpldis, fphdis , and fpopen bits in the fprot register are set prior to launching the command.
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 485 rev 1.09 17.4.1.3.1 erase verify command the erase verify operation will verify that a flash array is erased. an example ?w to execute the erase verify operation is shown in figure 17-22 . the erase verify command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the erase verify command. the address and data written will be ignored. 2. write the erase verify command, 0x05, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the erase verify command. after launching the erase verify command, the ccif ?g in the fstat register will set after the operation has completed unless a new command write sequence has been buffered. upon completion of the erase verify operation, the blank ?g in the fstat register will be set if all addresses in the flash array are veri?d to be erased. if any address in the flash array is not erased, the erase verify operation will terminate and the blank ?g in the fstat register will remain clear.
chapter 17 32 kbyte flash module (s12fts32kv1) 486 mc9s12q128 freescale semiconductor rev 1.09 figure 17-22. example erase verify command flow write: flash array address write: fcmd register erase verify command 0x05 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and dummy data bit polling for command completion check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check ccif set? accerr/ pviol set? no erase verify status yes exit flash array not erased exit flash array erased blank set? write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset.
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 487 rev 1.09 17.4.1.3.2 program command the program operation will program a previously erased word in the flash array using an embedded algorithm. an example ?w to execute the program operation is shown in figure 17-23 . the program command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the program command. the data written will be programmed to the flash array address written. 2. write the program command, 0x20, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the program command. if a word to be programmed is in a protected area of the flash array, the pviol ?g in the fstat register will set and the program command will not launch. once the program command has successfully launched, the ccif ?g in the fstat register will set after the program operation has completed unless a new command write sequence has been buffered. by executing a new program command write sequence on sequential words after the cbeif ?g in the fstat register has been set, up to 55% faster programming time per word can be effectively achieved than by waiting for the ccif ?g to set after each program operation.
chapter 17 32 kbyte flash module (s12fts32kv1) 488 mc9s12q128 freescale semiconductor rev 1.09 figure 17-23. example program command flow write: flash address write: fcmd register program command 0x20 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and program data bit polling for buffer empty check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check cbeif set? accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no yes sequential programming decision next word? no bit polling for command completion check read: fstat register yes ccif set?
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 489 rev 1.09 17.4.1.3.3 sector erase command the sector erase operation will erase all addresses in a 512 byte sector of the flash array using an embedded algorithm. an example ?w to execute the sector erase operation is shown in figure 17-24 . the sector erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the sector erase command. the flash address written determines the sector to be erased while mcu address bits [8:0] and the data written are ignored. 2. write the sector erase command, 0x40, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the sector erase command. if a flash sector to be erased is in a protected area of the flash array, the pviol ?g in the fstat register will set and the sector erase command will not launch. once the sector erase command has successfully launched, the ccif ?g in the fstat register will set after the sector erase operation has completed unless a new command write sequence has been buffered.
chapter 17 32 kbyte flash module (s12fts32kv1) 490 mc9s12q128 freescale semiconductor rev 1.09 figure 17-24. example sector erase command flow write: flash sector address write: fcmd register sector erase command 0x40 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 491 rev 1.09 17.4.1.3.4 mass erase command the mass erase operation will erase all addresses in a flash array using an embedded algorithm. an example ?w to execute the mass erase operation is shown in figure 17-25 . the mass erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the mass erase command. the address and data written will be ignored. 2. write the mass erase command, 0x41, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the mass erase command. if a flash array to be erased contains any protected area, the pviol ?g in the fstat register will set and the mass erase command will not launch. once the mass erase command has successfully launched, the ccif ?g in the fstat register will set after the mass erase operation has completed unless a new command write sequence has been buffered.
chapter 17 32 kbyte flash module (s12fts32kv1) 492 mc9s12q128 freescale semiconductor rev 1.09 figure 17-25. example mass erase command flow write: flash block address write: fcmd register mass erase command 0x41 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 493 rev 1.09 17.4.1.4 illegal flash operations 17.4.1.4.1 access error the accerr ?g in the fstat register will be set during the command write sequence if any of the following illegal flash operations are performed causing the command write sequence to immediately abort: 1. writing to the flash address space before initializing the fclkdiv register 2. writing a misaligned word or a byte to the valid flash address space 3. writing to the flash address space while cbeif is not set 4. writing a second word to the flash address space before executing a program or erase command on the previously written word 5. writing to any flash register other than fcmd after writing a word to the flash address space 6. writing a second command to the fcmd register before executing the previously written command 7. writing an invalid command to the fcmd register 8. writing to any flash register other than fstat (to clear cbeif) after writing to the fcmd register 9. the part enters stop mode and a program or erase command is in progress. the command is aborted and any pending command is killed 10. when security is enabled, a command other than mass erase originating from a non-secure memory or from the background debug mode is written to the fcmd register 11. a 0 is written to the cbeif bit in the fstat register to abort a command write sequence. the accerr ?g will not be set if any flash register is read during the command write sequence. if the flash array is read during execution of an algorithm (ccif=0), the flash module will return invalid data and the accerr ?g will not be set. if an accerr ?g is set in the fstat register, the flash command controller is locked. it is not possible to launch another command until the accerr ?g is cleared. 17.4.1.4.2 protection violation the pviol ?g in the fstat register will be set during the command write sequence after the word write to the flash address space if any of the following illegal flash operations are performed, causing the command write sequence to immediately abort: 1. writing a flash address to program in a protected area of the flash array (see section 17.3.2.5 ). 2. writing a flash address to erase in a protected area of the flash array. 3. writing the mass erase command to the fcmd register while any protection is enabled. if the pviol ?g is set, the flash command controller is locked. it is not possible to launch another command until the pviol ?g is cleared.
chapter 17 32 kbyte flash module (s12fts32kv1) 494 mc9s12q128 freescale semiconductor rev 1.09 17.4.2 operating modes 17.4.2.1 wait mode if the mcu enters wait mode while a flash command is active (ccif = 0), that command and any buffered command will be completed. the flash module can recover the mcu from wait mode if the interrupts are enabled (see section 17.4.5 ). 17.4.2.2 stop mode if the mcu enters stop mode while a flash command is active (ccif = 0), that command will be aborted and the data being programmed or erased is lost. the high voltage circuitry to the flash array will be switched off when entering stop mode. ccif and accerr ?gs will be set. upon exit from stop mode, the cbeif ?g will be set and any buffered command will not be executed. the accerr ?g must be cleared before returning to normal operation. note as active flash commands are immediately aborted when the mcu enters stop mode, it is strongly recommended that the user does not use the stop instruction during program and erase execution. 17.4.2.3 background debug mode in background debug mode (bdm), the fprot register is writable. if the mcu is unsecured, then all flash commands listed in table 17-16 can be executed. if the mcu is secured and is in special single chip mode, the only possible command to execute is mass erase. 17.4.3 flash module security the flash module provides the necessary security information to the mcu. after each reset, the flash module determines the security state of the mcu as de?ed in section 17.3.2.2, ?lash security register (fsec) . the contents of the flash security/options byte at address 0xff0f in the flash con?uration ?ld must be changed directly by programming address 0xff0f when the device is unsecured and the higher address sector is unprotected. if the flash security/options byte is left in the secure state, any reset will cause the mcu to return to the secure operating mode. 17.4.3.1 unsecuring the mcu using backdoor key access the mcu may only be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor key (four 16-bit words programmed at addresses 0xff00?xff07). if keyen[1:0] = 1:0 and the keyacc bit is set, a write to a backdoor key address in the flash array triggers a comparison between the written data and the backdoor key data stored in the flash array. if all four words of data are written to the correct addresses in the correct order and the data matches the backdoor key stored in the flash array, the mcu will be unsecured. the data must be written to the backdoor key
chapter 17 32 kbyte flash module (s12fts32kv1) freescale semiconductor mc9s12q128 495 rev 1.09 addresses sequentially staring with 0xff00-0xff01 and ending with 0xff06?xff07. the values 0x0000 and 0xffff are not permitted as keys. when the keyacc bit is set, reads of the flash array will return invalid data. the user code stored in the flash array must have a method of receiving the backdoor key from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if keyen[1:0] = 1:0 in the fsec register, the mcu can be unsecured by the backdoor key access sequence described below: 1. set the keyacc bit in the fcnfg register 2. write the correct four 16-bit words to flash addresses 0xff00?xff07 sequentially starting with 0xff00 3. clear the keyacc bit in the fcnfg register 4. if all four 16-bit words match the backdoor key stored in flash addresses 0xff00?xff07, the mcu is unsecured and bits sec[1:0] in the fsec register are forced to the unsecure state of 1:0 the backdoor key access sequence is monitored by the internal security state machine. an illegal operation during the backdoor key access sequence will cause the security state machine to lock, leaving the mcu in the secured state. a reset of the mcu will cause the security state machine to exit the lock state and allow a new backdoor key access sequence to be attempted. the following illegal operations will lock the security state machine: 1. if any of the four 16-bit words does not match the backdoor key programmed in the flash array 2. if the four 16-bit words are written in the wrong sequence 3. if more than four 16-bit words are written 4. if any of the four 16-bit words written are 0x0000 or 0xffff 5. if the keyacc bit does not remain set while the four 16-bit words are written after the backdoor key access sequence has been correctly matched, the mcu will be unsecured. the flash security byte can be programmed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the four word backdoor key by programming bytes 0xff00?xff07 of the flash con?uration ?ld. the security as de?ed in the flash security/options byte at address 0xff0f is not changed by using the backdoor key access sequence to unsecure. the backdoor key stored in addresses 0xff00?xff07 is unaffected by the backdoor key access sequence. after the next reset sequence, the security state of the flash module is determined by the flash security/options byte at address 0xff0f. the backdoor key access sequence has no effect on the program and erase protection de?ed in the fprot register. it is not possible to unsecure the mcu in special single chip mode by executing the backdoor key access sequence in background debug mode.
chapter 17 32 kbyte flash module (s12fts32kv1) 496 mc9s12q128 freescale semiconductor rev 1.09 17.4.4 flash reset sequence on each reset, the flash module executes a reset sequence to hold cpu activity while loading the following registers from the flash array memory according to table 17-1 : fprot ?flash protection register (see section 17.3.2.5 ) fsec ?flash security register (see section 17.3.2.2 ) 17.4.4.1 reset while flash command active if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/array being erased is not guaranteed. 17.4.5 interrupts the flash module can generate an interrupt when all flash commands have completed execution or the flash address, data, and command buffers are empty. note vector addresses and their relative interrupt priority are determined at the mcu level. 17.4.5.1 description of interrupt operation figure 17-26 shows the logic used for generating interrupts. the flash module uses the cbeif and ccif ?gs in combination with the enable bits cbie and ccie to discriminate for the generation of interrupts. figure 17-26. flash interrupt implementation for a detailed description of these register bits, refer to section 17.3.2.4, ?lash con?uration register (fcnfg) and section 17.3.2.6, ?lash status register (fstat) . table 17-17. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash address, data, and command buffers are empty cbeif (fstat register) cbeie i bit all flash commands have completed execution ccif (fstat register) ccie i bit cbeif cbeie ccif ccie flash interrupt request
freescale semiconductor mc9s12q128 497 rev 1.09 chapter 18 64 kbyte flash module (s12fts64kv4) 18.1 introduction the fts64k module implements a 64 kbyte flash (nonvolatile) memory. the flash memory contains one array of 64 kbytes organized as 512 rows of 128 bytes with an erase sector size of eight rows ( 1024 bytes). the flash array may be read as either bytes, aligned words, or misaligned words. read access time is one bus cycle for byte and aligned word, and two bus cycles for misaligned words. the flash array is ideal for program and data storage for single-supply applications allowing for ?ld reprogramming without requiring external voltage sources for program or erase. program and erase functions are controlled by a command driven interface. the flash module supports both mass erase and sector erase. an erased bit reads 1 and a programmed bit reads 0. the high voltage required to program and erase is generated internally. it is not possible to read from a flash array while it is being erased or programmed. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. 18.1.1 glossary command write sequence a three-step mcu instruction sequence to program, erase, or erase verify the flash array memory. 18.1.2 features 64 kbytes of flash memory comprised of one 64 kbyte array divided into 64 sectors of 1024 bytes automated program and erase algorithm interrupts on flash command completion and command buffer empty fast sector erase and word program operation 2-stage command pipeline for faster multi-word program times flexible protection scheme to prevent accidental program or erase single power supply for flash program and erase operations security feature to prevent unauthorized access to the flash array memory
chapter 18 64 kbyte flash module (s12fts64kv4) 498 mc9s12q128 freescale semiconductor rev 1.09 18.1.3 modes of operation see section 18.4.2, ?perating modes ?for a description of the flash module operating modes. for program and erase operations, refer to section 18.4.1, ?lash command operations . 18.1.4 block diagram figure 18-1 shows a block diagram of the fts64k module. figure 18-1. fts64k block diagram 18.2 external signal description the fts64k module contains no signals that connect off-chip. fts64k oscillator clock command complete interrupt command buffer empty interrupt flash array 32k * 16 bits sector 0 sector 1 sector 63 clock divider fclk protection security command pipeline cmd2 addr2 data2 cmd1 addr1 data1 registers flash interface
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 499 rev 1.09 18.3 memory map and registers this section describes the fts64k memory map and registers. 18.3.1 module memory map the fts64k memory map is shown in figure 18-2 . the hcs12 architecture places the flash array addresses between 0x4000 and 0xffff , which corresponds to three 16 kbyte pages . the content of the hcs12 core ppage register is used to map the logical middle page ranging from address 0x8000 to 0xbfff to a ny physical 16k byte page in the flash array memory. 1 the fprot register (see section 18.3.2.5 ) can be set to globally protect the entire flash array . three separate areas, one starting from the flash array starting address (called lower) towards higher addresses, one growing downward from the flash array end address (called higher), and the remaining addresses, can be activated for protection . the flash array addresses covered by these protectable regions are shown in figure 18-2. the higher address area is mainly targeted to hold the boot loader code since it covers the vector space. the lower address area can be used for eeprom emulation in an mcu without an eeprom module since it can be left unprotected while the remaining addresses are protected from program or erase. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld described in table 18-1 . 1. by placing 0x3e/ 0x3f in the hcs12 core ppage register, the bottom/top ?ed 16 kbyte page s can be seen twice in the mcu memory map. table 18-1. flash con?uration field flash address size (bytes) description 0xff00?xff07 8 backdoor key to unlock security 0xff08?xff0c 5 reserved 0xff0d 1 flash protection byte refer to section 18.3.2.5, ?lash protection register (fprot) 0xff0e 1 reserved 0xff0f 1 flash security/options byte refer to section 18.3.2.2, ?lash security register (fsec)
chapter 18 64 kbyte flash module (s12fts64kv4) 500 mc9s12q128 freescale semiconductor rev 1.09 figure 18-2. flash memory map flash registers module base + 0x0000 0xff00?xff0f (flash con?uration field) module base + 0x000f 0x8000 flash protected low sectors 1, 2, 4, 8 kbytes flash_start = 0x4000 0x5000 0x4400 0x6000 16k paged memory 0x3e 0x3c 0x3d 003e 0x3f note: 0x3c?x3f correspond to the ppage register content flash_end = 0xffff 0xf800 0xf000 0xc000 0xe000 flash protected high sectors 2, 4, 8, 16 kbytes 0x3f 0x4800 flash array 16 bytes
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 501 rev 1.09 table 18-2. flash array memory map summary mcu address range ppage protectable low range protectable high range array relative address (1) 1. inside flash block. 0x0000?x3fff (2) 2. if allowed by mcu. unpaged (0x3d) n.a. n.a. 0x14000?x17fff 0x4000?x7fff unpaged (0x3e) 0x4000?x43ff n.a. 0x18000?x1bfff 0x4000?x47ff 0x4000?x4fff 0x4000?x5fff 0x8000?xbfff 0x3c n.a. n.a. 0x10000?x13fff 0x3d n.a. n.a. 0x14000?x17fff 0x3e 0x8000?x83ff n.a. 0x18000?x1bfff 0x8000?x87ff 0x8000?x8fff 0x8000?x9fff 0x3f n.a. 0xb800?xbfff 0x1c000?x1ffff 0xb000?xbfff 0xa000?xbfff 0x8000?xbfff 0xc000?xffff unpaged (0x3f) n.a. 0xf800?xffff 0x1c000?x1ffff 0xf000?xffff 0xe000?xffff 0xc000?xffff
chapter 18 64 kbyte flash module (s12fts64kv4) 502 mc9s12q128 freescale semiconductor rev 1.09 18.3.2 register descriptions the flash module contains a set of 16 control and status registers located between module base + 0x0000 and 0x000f. a summary of the flash module registers is given in figure 18-3 . detailed descriptions of each register bit are provided. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 fclkdiv r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w 0x0002 reserved1 (1) 1. intended for factory test purposes only. r00000000 w 0x0003 fcnfg r cbeie ccie keyacc 00000 w 0x0004 fprot r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0005 fstat r cbeif ccif pviol accerr 0 blank fail done w 0x0006 fcmd r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w 0x0007 reserved2 1 r00000000 w 0x0008 faddrhi 1 r 0 fabhi w 0x0009 faddrlo 1 r fablo w 0x000a fdatahi 1 r fdhi w 0x000b fdatalo 1 r fdlo w 0x000c reserved3 1 r00000000 w 0x000d reserved4 1 r00000000 w 0x000e reserved5 1 r00000000 w 0x000f reserved6 1 r00000000 w = unimplemented or reserved figure 18-3. flash register summary
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 503 rev 1.09 18.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bits 6? are write once and bit 7 is not writable. 18.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. the fsec register is loaded from the flash con?uration ?ld at 0xff0f during the reset sequence, indicated by f in figure 18-5 . module base + 0x0000 76543210 r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w reset 00000000 = unimplemented or reserved figure 18-4. flash clock divider register (fclkdiv) table 18-3. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written 1 fclkdiv register has been written to since the last reset 6 prdiv8 enable prescalar by 8 0 the oscillator clock is directly fed into the flash clock divider 1 the oscillator clock is divided by 8 before feeding into the flash clock divider 5? fdiv[5:0] clock divider bits ?the combination of prdiv8 and fdiv[5:0] must divide the oscillator clock down to a frequency of 150 khz ?200 khz. the maximum divide ratio is 512. refer to section 18.4.1.1, ?riting the fclkdiv register for more information. module base + 0x0001 76543210 r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w reset f f ffffff = unimplemented or reserved figure 18-5. flash security register (fsec)
chapter 18 64 kbyte flash module (s12fts64kv4) 504 mc9s12q128 freescale semiconductor rev 1.09 the security function in the flash module is described in section 18.4.3, ?lash module security . 18.3.2.3 reserved1 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. table 18-4. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits ?the keyen[1:0] bits de?e the enabling of the backdoor key access to the flash module as shown in table 18-5 . 5? nv[5:2] nonvolatile flag bits ?the nv[5:2] bits are available to the user as nonvolatile ?gs. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 18-6 . if the flash module is unsecured using backdoor key access, the sec[1:0] bits are forced to 1:0. table 18-5. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 (1) 1. preferred keyen state to disable backdoor key access. disabled 10 enabled 11 disabled table 18-6. flash security states sec[1:0] status of security 00 secured 01 (1) 1. preferred sec state to set mcu to secured state. secured 10 unsecured 11 secured module base + 0x0002 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 18-6. reserved1
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 505 rev 1.09 18.3.2.4 flash con?uration register (fcnfg) the fcnfg register enables the flash interrupts and gates the security backdoor key writes. cbeie, ccie, and keyacc are readable and writable while remaining bits read 0 and are not writable. keyacc is only writable if the keyen bit in the fsec register is set to the enabled state (see section 18.3.2.2 ). 18.3.2.5 flash protection register (fprot) the fprot register de?es which flash sectors are protected against program or erase. the fprot register is readable in normal and special modes. fpopen can only be written from a 1 to a 0. fpls[1:0] can be written anytime until fpldis is cleared. fphs[1:0] can be written anytime until module base + 0x0003 76543210 r cbeie ccie keyacc 00000 w reset 00000000 = unimplemented or reserved figure 18-7. flash con?uration register (fcnfg) table 18-7. fcnfg field descriptions field description 7 cbeie command buffer empty interrupt enable ?the cbeie bit enables the interrupts in case of an empty command buffer in the flash module. 0 command buffer empty interrupts disabled 1 an interrupt will be requested whenever the cbeif ?g is set (see section 18.3.2.6 ) 6 ccie command complete interrupt enable ?the ccie bit enables the interrupts in case of all commands being completed in the flash module. 0 command complete interrupts disabled 1 an interrupt will be requested whenever the ccif ?g is set (see section 18.3.2.6 ) 5 keyacc enable security key writing . 0 flash writes are interpreted as the start of a command write sequence 1 writes to the flash array are interpreted as a backdoor key while reads of the flash array return invalid data module base + 0x0004 76543210 r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w reset f f ffffff figure 18-8. flash protection register (fprot)
chapter 18 64 kbyte flash module (s12fts64kv4) 506 mc9s12q128 freescale semiconductor rev 1.09 fphdis is cleared. the fprot register is loaded from flash address 0xff0d during the reset sequence, indicated by f in figure 18-8 . to change the flash protection that will be loaded on reset, the upper sector of the flash array must be unprotected, then the flash protection byte located at flash address 0xff0d must be written to. a protected flash sector is disabled by fphdis and fpldis while the size of the protected sector is de?ed by fphs[1:0] and fpls[1:0] in the fprot register. trying to alter any of the protected areas will result in a protect violation error and the pviol ?g will be set in the fstat register (see section 18.3.2.6 ). a mass erase of the whole flash array is only possible when protection is fully disabled by setting the fpopen , fpldis, and fphdis bits. an attempt to mass erase a flash array while protection is enabled will set the pviol ?g in the fstat register. table 18-8. fprot field descriptions field description 7 fpopen protection function for program or erase ?it is possible using the fpopen bit to either select address ranges to be protected using fphdis, fpldis, fphs[1:0] and fpls[1:0] or to select the same ranges to be unprotected. when fpopen is set, fpxdis enables the ranges to be protected, whereby clearing fpxdis enables protection for the range speci?d by the corresponding fpxs[1:0] bits. when fpopen is cleared, fpxdis de?es unprotected ranges as speci?d by the corresponding fpxs[1:0] bits. in this case, setting fpxdis enables protection. thus the effective polarity of the fpxdis bits is swapped by the fpopen bit as shown in table 18-9 . this function allows the main part of the flash array to be protected while a small range can remain unprotected for eeprom emulation. 0 the fphdis and fpldis bits de?e flash address ranges to be unprotected 1 the fphdis and fpldis bits de?e flash address ranges to be protected 6 nv6 nonvolatile flag bit ?the nv6 bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in the higher space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs[1:0] bits determine the size of the protected/unprotected sector as shown in table 18-10 . the fphs[1:0] bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected sector in the lower space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls[1:0] bits determine the size of the protected/unprotected sector as shown in table 18-11 . the fpls[1:0] bits can only be written to while the fpldis bit is set.
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 507 rev 1.09 figure 18-9 illustrates all possible protection scenarios. although the protection scheme is loaded from the flash array after reset, it is allowed to change in normal modes. this protection scheme can be used by applications requiring re-programming in single chip mode while providing as much protection as possible if no re-programming is required. table 18-9. flash protection function fpopen fphdis fphs[1] fphs[0] fpldis fpls[1] fpls[0] function (1) 1. for range sizes refer to table 18-10 and table 18-11 or . 1 1 x x 1 x x no protection 1 1 x x 0 x x protect low range 1 0 x x 1 x x protect high range 1 0 x x 0 x x protect high and low ranges 0 1 x x 1 x x full flash array protected 0 0 x x 1 x x unprotected high range 0 1 x x 0 x x unprotected low range 0 0 x x 0 x x unprotected high and low ranges table 18-10. flash protection higher address range fphs[1:0] address range range size 00 0xf800?xffff 2 kbytes 01 0xf000?xffff 4 kbytes 10 0xe000?xffff 8 kbytes 11 0xc000?xffff 16 kbytes table 18-11. flash protection lower address range fpls[1:0] address range range size 00 0x4000?x43ff 1 kbyte 01 0x4000?x47ff 2 kbytes 10 0x4000?x4fff 4 kbytes 11 0x4000?x5fff 8 kbytes
chapter 18 64 kbyte flash module (s12fts64kv4) 508 mc9s12q128 freescale semiconductor rev 1.09 figure 18-9. flash protection scenarios 18.3.2.5.1 flash protection restrictions the general guideline is that protection can only be added, not removed. all valid transitions between flash protection scenarios are speci?d in table 18-12 . any attempt to write an invalid scenario to the fprot register will be ignored and the fprot register will remain unchanged. the contents of the fprot register re?ct the active protection scenario. table 18-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567 0 xxxx 1xx 2xx 3x 4xx 5 xxxx 7 6 5 4 fpopen = 1 3 2 1 0 fphs[1:0] fpls[1:0] fpopen = 0 fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario protected flash fphs[1:0] fpls[1:0] 0xffff 0xffff
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 509 rev 1.09 18.3.2.6 flash status register (fstat) the fstat register de?es the status of the flash command controller and the results of command execution. in normal modes, bits cbeif, pviol, and accerr are readable and writable, bits ccif and blank are readable and not writable, remaining bits, including fail and done, read 0 and are not writable. in special modes, fail is readable and writable while done is readable but not writable. fail must be clear in special modes when starting a command write sequence. 6xxxx 7 xxxxxxxx 1. allowed transitions marked with x. module base + 0x0005 76543210 r cbeif ccif pviol accerr 0 blank fail done w reset 11000001 = unimplemented or reserved figure 18-10. flash status register (fstat) table 18-13. fstat field descriptions field description 7 cbeif command buffer empty interrupt flag ?the cbeif ?g indicates that the address, data and command buffers are empty so that a new command write sequence can be started. the cbeif ?g is cleared by writing a 1 to cbeif. writing a 0 to the cbeif ?g has no effect on cbeif. writing a 0 to cbeif after writing an aligned word to the flash address space but before cbeif is cleared will abort a command write sequence and cause the accerr ?g in the fstat register to be set. writing a 0 to cbeif outside of a command write sequence will not set the accerr ?g. the cbeif ?g is used together with the cbeie bit in the fcnfg register to generate an interrupt request (see figure 18-26 ). 0 buffers are full 1 buffers are ready to accept a new command 6 ccif command complete interrupt flag the ccif ?g indicates that there are no more commands pending. the ccif ?g is cleared when cbeif is clear and sets automatically upon completion of all active and pending commands. the ccif ?g does not set when an active commands completes and a pending command is fetched from the command buffer. writing to the ccif ?g has no effect. the ccif ?g is used together with the ccie bit in the fcnfg register to generate an interrupt request (see figure 18-26 ). 0 command in progress 1 all commands are completed table 18-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567
chapter 18 64 kbyte flash module (s12fts64kv4) 510 mc9s12q128 freescale semiconductor rev 1.09 18.3.2.7 flash command register (fcmd) the fcmd register de?es the flash commands. bits cmdb6, cmdb5, cmdb2, and cmdb0 are readable and writable during a command write sequence while bits 7, 4, 3, and 1 read 0 and are not writable. 5 pviol protection violation ?the pviol ?g indicates an attempt was made to program or erase an address in a protected flash array memory area. the pviol ?g is cleared by writing a 1 to pviol. writing a 0 to the pviol ?g has no effect on pviol. while pviol is set, it is not possible to launch another command. 0 no protection violation detected 1 protection violation has occurred 4 accerr access error the accerr ?g indicates an illegal access to the flash array caused by either a violation of the command write sequence, issuing an illegal command (illegal combination of the cmdbx bits in the fcmd register) or the execution of a cpu stop instruction while a command is executing (ccif=0). the accerr ?g is cleared by writing a 1 to accerr. writing a 0 to the accerr ?g has no effect on accerr. while accerr is set, it is not possible to launch another command. 0 no access error detected 1 access error has occurred 2 blank flash array has been veri?d as erased ?the blank ?g indicates that an erase verify command has checked the flash array and found it to be erased. the blank ?g is cleared by hardware when cbeif is cleared as part of a new valid command write sequence. writing to the blank ?g has no effect on blank. 0 if an erase verify command has been requested, and the ccif ?g is set, then a 0 in blank indicates the array is not erased 1 flash array veri?s as erased 1 fail flag indicating a failed flash operation in special modes, the fail ?g will set if the erase verify operation fails (flash array veri?d as not erased). writing a 0 to the fail ?g has no effect on fail. the fail ?g is cleared by writing a 1 to fail. while fail is set, it is not possible to launch another command. 0 flash operation completed without error 1 flash operation failed 0 done flag indicating a failed operation is not active ?in special modes, the done ?g will clear if a program, erase, or erase verify operation is active. 0 flash operation is active 1 flash operation is not active module base + 0x0006 76543210 r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w reset 00000000 = unimplemented or reserved figure 18-11. flash command register (fcmd) table 18-13. fstat field descriptions field description
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 511 rev 1.09 18.3.2.8 reserved2 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 18.3.2.9 flash address register (faddr) faddrhi and faddrlo are the flash address registers. \ \ table 18-14. fcmd field descriptions field description 6, 5, 2, 0 cmdb[6:5] cmdb[2] cmdb[0] valid flash commands are shown in table 18-15 . an attempt to execute any command other than those listed in table 18-15 will set the accerr bit in the fstat register (see section 18.3.2.6 ). table 18-15. valid flash command list cmdb nvm command 0x05 erase verify 0x20 word program 0x40 sector erase 0x41 mass erase module base + 0x0007 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 18-12. reserved2 module base + 0x0008 76543210 r0 fabhi w reset 00000000 = unimplemented or reserved figure 18-13. flash address high register (faddrhi)
chapter 18 64 kbyte flash module (s12fts64kv4) 512 mc9s12q128 freescale semiconductor rev 1.09 in normal modes, all fabhi and fablo bits read 0 and are not writable. in special modes, the fabhi and fablo bits are readable and writable. for sector erase, the mcu address bits [9:0] are ignored .for mass erase, any address within the flash array is valid to start the command. 18.3.2.10 flash data register (fdata) fdatahi and fdatalo are the flash data registers. in normal modes, all fdatahi and fdatalo bits read 0 and are not writable. in special modes, all fdatahi and fdatalo bits are readable and writable when writing to an address within the flash address range. 18.3.2.11 reserved3 this register is reserved for factory testing and is not accessible to the user. module base + 0x0009 76543210 r fablo w reset 00000000 figure 18-14. flash address low register (faddrlo) module base + 0x000a 76543210 r fdhi w reset 00000000 figure 18-15. flash data high register (fdatahi) module base + 0x000b 76543210 r fdlo w reset 00000000 figure 18-16. flash data low register (fdatalo)
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 513 rev 1.09 all bits read 0 and are not writable. 18.3.2.12 reserved4 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 18.3.2.13 reserved5 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 18.3.2.14 reserved6 this register is reserved for factory testing and is not accessible to the user. module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 18-17. reserved3 module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 18-18. reserved4 module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 18-19. reserved5
chapter 18 64 kbyte flash module (s12fts64kv4) 514 mc9s12q128 freescale semiconductor rev 1.09 all bits read 0 and are not writable. 18.4 functional description 18.4.1 flash command operations write operations are used for the program, erase, and erase verify algorithms described in this section. the program and erase algorithms are controlled by a state machine whose timebase fclk is derived from the oscillator clock via a programmable divider. the fcmd register as well as the associated faddr and fdata registers operate as a buffer and a register (2-stage fifo) so that a new command along with the necessary data and address can be stored to the buffer while the previous command is still in progress. this pipelined operation allows a time optimization when programming more than one word on a speci? row, as the high voltage generation can be kept active in between two programming commands. the pipelined operation also allows a simpli?ation of command launching. buffer empty as well as command completion are signalled by ?gs in the fstat register with corresponding interrupts generated, if enabled. the next sections describe: how to write the fclkdiv register command write sequence used to program, erase or erase verify the flash array valid flash commands errors resulting from illegal flash operations 18.4.1.1 writing the fclkdiv register prior to issuing any flash command after a reset, it is ?st necessary to write the fclkdiv register to divide the oscillator clock down to within the 150-khz to 200-khz range. since the program and erase timings are also a function of the bus clock, the fclkdiv determination must take this information into account. if we de?e: fclk as the clock of the flash timing control block tbus as the period of the bus clock int(x) as taking the integer part of x (e.g., int(4.323) = 4), module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 18-20. reserved6
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 515 rev 1.09 then fclkdiv register bits prdiv8 and fdiv[5:0] are to be set as described in figure 18-21 . for example, if the oscillator clock frequency is 950 khz and the bus clock is 10 mhz, fclkdiv bits fdiv[5:0] should be set to 4 (000100) and bit prdiv8 set to 0. the resulting fclk is then 190 khz. as a result, the flash algorithm timings are increased over optimum target by: command execution time will increase proportionally with the period of fclk. caution because of the impact of clock synchronization on the accuracy of the functional timings, programming or erasing the flash array cannot be performed if the bus clock runs at less than 1 mhz. programming or erasing the flash array with an input clock < 150 khz should be avoided. setting fclkdiv to a value such that fclk < 150 khz can destroy the flash array due to overstress. setting fclkdiv to a value such that (1/fclk + tbus) < 5 s can result in incomplete programming or erasure of the flash array cells. if the fclkdiv register is written, the bit fdivld is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written to, the flash command loaded during a command write sequence will not execute and the accerr ?g in the fstat register will set. 200 190 () 200 ? 100 5% =
chapter 18 64 kbyte flash module (s12fts64kv4) 516 mc9s12q128 freescale semiconductor rev 1.09 figure 18-21. prdiv8 and fdiv bits determination procedure prdiv8=1 yes no prdiv8=0 (reset) 12.8mhz? fclk=(prdclk)/(1+fdiv[5:0]) prdclk=oscillator_clock prdclk=oscillator_clock/8 prdclk[mhz]*(5+tbus[ s]) no fdiv[5:0]=prdclk[mhz]*(5+tbus[ s])-1 yes start tbus < 1 s? an integer? fdiv[5:0]=int(prdclk[mhz]*(5+tbus[ s])) 1/fclk[mhz] + tbus[ s] > 5 and fclk > 0.15mhz ? end yes no fdiv[5:0] > 4? all commands impossible yes no all commands impossible no try to decrease tbus yes oscillator_clock
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 517 rev 1.09 18.4.1.2 command write sequence the flash command controller is used to supervise the command write sequence to execute program, erase, and erase verify algorithms. before starting a command write sequence, the accerr and pviol ?gs in the fstat register must be clear and the cbeif ?g should be tested to determine the state of the address, data, and command buffers. if the cbeif ?g is set, indicating the buffers are empty, a new command write sequence can be started. if the cbeif ?g is clear, indicating the buffers are not available, a new command write sequence will overwrite the contents of the address, data, and command buffers. a command write sequence consists of three steps which must be strictly adhered to with writes to the flash module not permitted between the steps. however, flash register and array reads are allowed during a command write sequence. the basic command write sequence is as follows: 1. write to a valid address in the flash array memory. 2. write a valid command to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the command. the address written in step 1 will be stored in the faddr registers and the data will be stored in the fdata registers. when the cbeif ?g is cleared in step 3, the ccif ?g is cleared by the flash command controller indicating that the command was successfully launched. for all command write sequences, the cbeif ?g will set after the ccif ?g is cleared indicating that the address, data, and command buffers are ready for a new command write sequence to begin. a buffered command will wait for the active operation to be completed before being launched. once a command is launched, the completion of the command operation is indicated by the setting of the ccif ?g in the fstat register. the ccif ?g will set upon completion of all active and buffered commands.
chapter 18 64 kbyte flash module (s12fts64kv4) 518 mc9s12q128 freescale semiconductor rev 1.09 18.4.1.3 valid flash commands table 18-16 summarizes the valid flash commands along with the effects of the commands on the flash array. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. table 18-16. valid flash commands fcmd meaning function on flash array 0x05 erase verify verify all bytes in the flash array are erased. if the flash array is erased, the blank bit will set in the fstat register upon command completion. 0x20 program program a word (2 bytes) in the flash array. 0x40 sector erase erase all 1024 bytes in a sector of the flash array. 0x41 mass erase erase all bytes in the flash array. a mass erase of the full flash array is only possible when fpldis, fphdis , and fpopen bits in the fprot register are set prior to launching the command.
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 519 rev 1.09 18.4.1.3.1 erase verify command the erase verify operation will verify that a flash array is erased. an example ?w to execute the erase verify operation is shown in figure 18-22 . the erase verify command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the erase verify command. the address and data written will be ignored. 2. write the erase verify command, 0x05, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the erase verify command. after launching the erase verify command, the ccif ?g in the fstat register will set after the operation has completed unless a new command write sequence has been buffered. upon completion of the erase verify operation, the blank ?g in the fstat register will be set if all addresses in the flash array are veri?d to be erased. if any address in the flash array is not erased, the erase verify operation will terminate and the blank ?g in the fstat register will remain clear.
chapter 18 64 kbyte flash module (s12fts64kv4) 520 mc9s12q128 freescale semiconductor rev 1.09 figure 18-22. example erase verify command flow write: flash array address write: fcmd register erase verify command 0x05 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and dummy data bit polling for command completion check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check ccif set? accerr/ pviol set? no erase verify status yes exit flash array not erased exit flash array erased blank set? write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset.
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 521 rev 1.09 18.4.1.3.2 program command the program operation will program a previously erased word in the flash array using an embedded algorithm. an example ?w to execute the program operation is shown in figure 18-23 . the program command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the program command. the data written will be programmed to the flash array address written. 2. write the program command, 0x20, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the program command. if a word to be programmed is in a protected area of the flash array, the pviol ?g in the fstat register will set and the program command will not launch. once the program command has successfully launched, the ccif ?g in the fstat register will set after the program operation has completed unless a new command write sequence has been buffered. by executing a new program command write sequence on sequential words after the cbeif ?g in the fstat register has been set, up to 55% faster programming time per word can be effectively achieved than by waiting for the ccif ?g to set after each program operation.
chapter 18 64 kbyte flash module (s12fts64kv4) 522 mc9s12q128 freescale semiconductor rev 1.09 figure 18-23. example program command flow write: flash address write: fcmd register program command 0x20 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and program data bit polling for buffer empty check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check cbeif set? accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no yes sequential programming decision next word? no bit polling for command completion check read: fstat register yes ccif set?
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 523 rev 1.09 18.4.1.3.3 sector erase command the sector erase operation will erase all addresses in a 1024 byte sector of the flash array using an embedded algorithm. an example ?w to execute the sector erase operation is shown in figure 18-24 . the sector erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the sector erase command. the flash address written determines the sector to be erased while mcu address bits [9:0] and the data written are ignored. 2. write the sector erase command, 0x40, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the sector erase command. if a flash sector to be erased is in a protected area of the flash array, the pviol ?g in the fstat register will set and the sector erase command will not launch. once the sector erase command has successfully launched, the ccif ?g in the fstat register will set after the sector erase operation has completed unless a new command write sequence has been buffered.
chapter 18 64 kbyte flash module (s12fts64kv4) 524 mc9s12q128 freescale semiconductor rev 1.09 figure 18-24. example sector erase command flow write: flash sector address write: fcmd register sector erase command 0x40 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 525 rev 1.09 18.4.1.3.4 mass erase command the mass erase operation will erase all addresses in a flash array using an embedded algorithm. an example ?w to execute the mass erase operation is shown in figure 18-25 . the mass erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the mass erase command. the address and data written will be ignored. 2. write the mass erase command, 0x41, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the mass erase command. if a flash array to be erased contains any protected area, the pviol ?g in the fstat register will set and the mass erase command will not launch. once the mass erase command has successfully launched, the ccif ?g in the fstat register will set after the mass erase operation has completed unless a new command write sequence has been buffered.
chapter 18 64 kbyte flash module (s12fts64kv4) 526 mc9s12q128 freescale semiconductor rev 1.09 figure 18-25. example mass erase command flow write: flash block address write: fcmd register mass erase command 0x41 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 527 rev 1.09 18.4.1.4 illegal flash operations 18.4.1.4.1 access error the accerr ?g in the fstat register will be set during the command write sequence if any of the following illegal flash operations are performed causing the command write sequence to immediately abort: 1. writing to the flash address space before initializing the fclkdiv register 2. writing a misaligned word or a byte to the valid flash address space 3. writing to the flash address space while cbeif is not set 4. writing a second word to the flash address space before executing a program or erase command on the previously written word 5. writing to any flash register other than fcmd after writing a word to the flash address space 6. writing a second command to the fcmd register before executing the previously written command 7. writing an invalid command to the fcmd register 8. writing to any flash register other than fstat (to clear cbeif) after writing to the fcmd register 9. the part enters stop mode and a program or erase command is in progress. the command is aborted and any pending command is killed 10. when security is enabled, a command other than mass erase originating from a non-secure memory or from the background debug mode is written to the fcmd register 11. a 0 is written to the cbeif bit in the fstat register to abort a command write sequence. the accerr ?g will not be set if any flash register is read during the command write sequence. if the flash array is read during execution of an algorithm (ccif=0), the flash module will return invalid data and the accerr ?g will not be set. if an accerr ?g is set in the fstat register, the flash command controller is locked. it is not possible to launch another command until the accerr ?g is cleared. 18.4.1.4.2 protection violation the pviol ?g in the fstat register will be set during the command write sequence after the word write to the flash address space if any of the following illegal flash operations are performed, causing the command write sequence to immediately abort: 1. writing a flash address to program in a protected area of the flash array (see section 18.3.2.5 ). 2. writing a flash address to erase in a protected area of the flash array. 3. writing the mass erase command to the fcmd register while any protection is enabled. if the pviol ?g is set, the flash command controller is locked. it is not possible to launch another command until the pviol ?g is cleared.
chapter 18 64 kbyte flash module (s12fts64kv4) 528 mc9s12q128 freescale semiconductor rev 1.09 18.4.2 operating modes 18.4.2.1 wait mode if the mcu enters wait mode while a flash command is active (ccif = 0), that command and any buffered command will be completed. the flash module can recover the mcu from wait mode if the interrupts are enabled (see section 18.4.5 ). 18.4.2.2 stop mode if the mcu enters stop mode while a flash command is active (ccif = 0), that command will be aborted and the data being programmed or erased is lost. the high voltage circuitry to the flash array will be switched off when entering stop mode. ccif and accerr ?gs will be set. upon exit from stop mode, the cbeif ?g will be set and any buffered command will not be executed. the accerr ?g must be cleared before returning to normal operation. note as active flash commands are immediately aborted when the mcu enters stop mode, it is strongly recommended that the user does not use the stop instruction during program and erase execution. 18.4.2.3 background debug mode in background debug mode (bdm), the fprot register is writable. if the mcu is unsecured, then all flash commands listed in table 18-16 can be executed. if the mcu is secured and is in special single chip mode, the only possible command to execute is mass erase. 18.4.3 flash module security the flash module provides the necessary security information to the mcu. after each reset, the flash module determines the security state of the mcu as de?ed in section 18.3.2.2, ?lash security register (fsec) . the contents of the flash security/options byte at address 0xff0f in the flash con?uration ?ld must be changed directly by programming address 0xff0f when the device is unsecured and the higher address sector is unprotected. if the flash security/options byte is left in the secure state, any reset will cause the mcu to return to the secure operating mode. 18.4.3.1 unsecuring the mcu using backdoor key access the mcu may only be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor key (four 16-bit words programmed at addresses 0xff00?xff07). if keyen[1:0] = 1:0 and the keyacc bit is set, a write to a backdoor key address in the flash array triggers a comparison between the written data and the backdoor key data stored in the flash array. if all four words of data are written to the correct addresses in the correct order and the data matches the backdoor key stored in the flash array, the mcu will be unsecured. the data must be written to the backdoor key
chapter 18 64 kbyte flash module (s12fts64kv4) freescale semiconductor mc9s12q128 529 rev 1.09 addresses sequentially staring with 0xff00-0xff01 and ending with 0xff06?xff07. the values 0x0000 and 0xffff are not permitted as keys. when the keyacc bit is set, reads of the flash array will return invalid data. the user code stored in the flash array must have a method of receiving the backdoor key from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if keyen[1:0] = 1:0 in the fsec register, the mcu can be unsecured by the backdoor key access sequence described below: 1. set the keyacc bit in the fcnfg register 2. write the correct four 16-bit words to flash addresses 0xff00?xff07 sequentially starting with 0xff00 3. clear the keyacc bit in the fcnfg register 4. if all four 16-bit words match the backdoor key stored in flash addresses 0xff00?xff07, the mcu is unsecured and bits sec[1:0] in the fsec register are forced to the unsecure state of 1:0 the backdoor key access sequence is monitored by the internal security state machine. an illegal operation during the backdoor key access sequence will cause the security state machine to lock, leaving the mcu in the secured state. a reset of the mcu will cause the security state machine to exit the lock state and allow a new backdoor key access sequence to be attempted. the following illegal operations will lock the security state machine: 1. if any of the four 16-bit words does not match the backdoor key programmed in the flash array 2. if the four 16-bit words are written in the wrong sequence 3. if more than four 16-bit words are written 4. if any of the four 16-bit words written are 0x0000 or 0xffff 5. if the keyacc bit does not remain set while the four 16-bit words are written after the backdoor key access sequence has been correctly matched, the mcu will be unsecured. the flash security byte can be programmed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the four word backdoor key by programming bytes 0xff00?xff07 of the flash con?uration ?ld. the security as de?ed in the flash security/options byte at address 0xff0f is not changed by using the backdoor key access sequence to unsecure. the backdoor key stored in addresses 0xff00?xff07 is unaffected by the backdoor key access sequence. after the next reset sequence, the security state of the flash module is determined by the flash security/options byte at address 0xff0f. the backdoor key access sequence has no effect on the program and erase protection de?ed in the fprot register. it is not possible to unsecure the mcu in special single chip mode by executing the backdoor key access sequence in background debug mode.
chapter 18 64 kbyte flash module (s12fts64kv4) 530 mc9s12q128 freescale semiconductor rev 1.09 18.4.4 flash reset sequence on each reset, the flash module executes a reset sequence to hold cpu activity while loading the following registers from the flash array memory according to table 18-1 : fprot ?flash protection register (see section 18.3.2.5 ) fsec ?flash security register (see section 18.3.2.2 ) 18.4.4.1 reset while flash command active if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/array being erased is not guaranteed. 18.4.5 interrupts the flash module can generate an interrupt when all flash commands have completed execution or the flash address, data, and command buffers are empty. note vector addresses and their relative interrupt priority are determined at the mcu level. 18.4.5.1 description of interrupt operation figure 18-26 shows the logic used for generating interrupts. the flash module uses the cbeif and ccif ?gs in combination with the enable bits cbie and ccie to discriminate for the generation of interrupts. figure 18-26. flash interrupt implementation for a detailed description of these register bits, refer to section 18.3.2.4, ?lash con?uration register (fcnfg) and section 18.3.2.6, ?lash status register (fstat) . table 18-17. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash address, data, and command buffers are empty cbeif (fstat register) cbeie i bit all flash commands have completed execution ccif (fstat register) ccie i bit cbeif cbeie ccif ccie flash interrupt request
freescale semiconductor mc9s12q128 531 rev 1.09 chapter 19 96 kbyte flash module (s12fts96kv1) 19.1 introduction the fts96k module implements a 96 kbyte flash (nonvolatile) memory. the flash memory contains one array of 96 kbytes organized as 768 rows of 128 bytes with an erase sector size of eight rows ( 1024 bytes). the flash array may be read as either bytes, aligned words, or misaligned words. read access time is one bus cycle for byte and aligned word, and two bus cycles for misaligned words. the flash array is ideal for program and data storage for single-supply applications allowing for ?ld reprogramming without requiring external voltage sources for program or erase. program and erase functions are controlled by a command driven interface. the flash module supports both mass erase and sector erase. an erased bit reads 1 and a programmed bit reads 0. the high voltage required to program and erase is generated internally. it is not possible to read from a flash array while it is being erased or programmed. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. 19.1.1 glossary command write sequence a three-step mcu instruction sequence to program, erase, or erase verify the flash array memory. 19.1.2 features 96 kbytes of flash memory comprised of one 96 kbyte array divided into 96 sectors of 1024 bytes automated program and erase algorithm interrupts on flash command completion and command buffer empty fast sector erase and word program operation 2-stage command pipeline for faster multi-word program times flexible protection scheme to prevent accidental program or erase single power supply for flash program and erase operations security feature to prevent unauthorized access to the flash array memory
chapter 19 96 kbyte flash module (s12fts96kv1) 532 mc9s12q128 freescale semiconductor rev 1.09 19.1.3 modes of operation see section 19.4.2, ?perating modes ?for a description of the flash module operating modes. for program and erase operations, refer to section 19.4.1, ?lash command operations . 19.1.4 block diagram figure 19-1 shows a block diagram of the fts96k module. figure 19-1. fts96k block diagram 19.2 external signal description the fts96k module contains no signals that connect off-chip. fts96k oscillator clock command complete interrupt command buffer empty interrupt flash array 48k * 16 bits sector 0 sector 1 sector 95 clock divider fclk protection security command pipeline cmd2 addr2 data2 cmd1 addr1 data1 registers flash interface
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 533 rev 1.09 19.3 memory map and registers this section describes the fts96k memory map and registers. 19.3.1 module memory map the fts96k memory map is shown in figure 19-2 . the hcs12 architecture places the flash array addresses between 0x4000 and 0xffff , which corresponds to three 16 kbyte pages . the content of the hcs12 core ppage register is used to map the logical middle page ranging from address 0x8000 to 0xbfff to a ny physical 16k byte page in the flash array memory. 1 the fprot register (see section 19.3.2.5 ) can be set to globally protect the entire flash array . three separate areas, one starting from the flash array starting address (called lower) towards higher addresses, one growing downward from the flash array end address (called higher), and the remaining addresses, can be activated for protection . the flash array addresses covered by these protectable regions are shown in figure 19-2. the higher address area is mainly targeted to hold the boot loader code since it covers the vector space. the lower address area can be used for eeprom emulation in an mcu without an eeprom module since it can be left unprotected while the remaining addresses are protected from program or erase. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld described in table 19-1 . 1. by placing 0x3e/ 0x3f in the hcs12 core ppage register, the bottom/top ?ed 16 kbyte page s can be seen twice in the mcu memory map. table 19-1. flash con?uration field flash address size (bytes) description 0xff00?xff07 8 backdoor key to unlock security 0xff08?xff0c 5 reserved 0xff0d 1 flash protection byte refer to section 19.3.2.5, ?lash protection register (fprot) 0xff0e 1 reserved 0xff0f 1 flash security/options byte refer to section 19.3.2.2, ?lash security register (fsec)
chapter 19 96 kbyte flash module (s12fts96kv1) 534 mc9s12q128 freescale semiconductor rev 1.09 figure 19-2. flash memory map flash registers module base + 0x0000 0xff00?xff0f (flash con?uration field) module base + 0x000f 0x8000 flash protected low sectors 1, 2, 4, 8 kbytes flash_start = 0x4000 0x5000 0x4400 0x6000 16k paged memory 0x3a 0x3b 0x3e 0x3c 0x3d 003e 0x3f note: 0x3a?x3f correspond to the ppage register content flash_end = 0xffff 0xf800 0xf000 0xc000 0xe000 flash protected high sectors 2, 4, 8, 16 kbytes 0x3f 0x4800 flash array 16 bytes
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 535 rev 1.09 table 19-2. flash array memory map summary mcu address range ppage protectable low range protectable high range array relative address (1) 1. inside flash block. 0x0000?x3fff (2) 2. if allowed by mcu. unpaged (0x3d) n.a. n.a. 0x14000?x17fff 0x4000?x7fff unpaged (0x3e) 0x4000?x43ff n.a. 0x18000?x1bfff 0x4000?x47ff 0x4000?x4fff 0x4000?x5fff 0x8000?xbfff 0x3a n.a. n.a. 0x08000?x0bfff 0x3b n.a. n.a. 0x0c000?x0ffff 0x3c n.a. n.a. 0x10000?x13fff 0x3d n.a. n.a. 0x14000?x17fff 0x3e 0x8000?x83ff n.a. 0x18000?x1bfff 0x8000?x87ff 0x8000?x8fff 0x8000?x9fff 0x3f n.a. 0xb800?xbfff 0x1c000?x1ffff 0xb000?xbfff 0xa000?xbfff 0x8000?xbfff 0xc000?xffff unpaged (0x3f) n.a. 0xf800?xffff 0x1c000?x1ffff 0xf000?xffff 0xe000?xffff 0xc000?xffff
chapter 19 96 kbyte flash module (s12fts96kv1) 536 mc9s12q128 freescale semiconductor rev 1.09 19.3.2 register descriptions the flash module contains a set of 16 control and status registers located between module base + 0x0000 and 0x000f. a summary of the flash module registers is given in figure 19-3 . detailed descriptions of each register bit are provided. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 fclkdiv r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w 0x0002 reserved1 (1) 1. intended for factory test purposes only. r00000000 w 0x0003 fcnfg r cbeie ccie keyacc 00000 w 0x0004 fprot r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0005 fstat r cbeif ccif pviol accerr 0 blank fail done w 0x0006 fcmd r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w 0x0007 reserved2 1 r00000000 w 0x0008 faddrhi 1 r fabhi w 0x0009 faddrlo 1 r fablo w 0x000a fdatahi 1 r fdhi w 0x000b fdatalo 1 r fdlo w 0x000c reserved3 1 r00000000 w 0x000d reserved4 1 r00000000 w 0x000e reserved5 1 r00000000 w 0x000f reserved6 1 r00000000 w = unimplemented or reserved figure 19-3. flash register summary
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 537 rev 1.09 19.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bits 6? are write once and bit 7 is not writable. 19.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. the fsec register is loaded from the flash con?uration ?ld at 0xff0f during the reset sequence, indicated by f in figure 19-5 . module base + 0x0000 76543210 r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w reset 00000000 = unimplemented or reserved figure 19-4. flash clock divider register (fclkdiv) table 19-3. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written 1 fclkdiv register has been written to since the last reset 6 prdiv8 enable prescalar by 8 0 the oscillator clock is directly fed into the flash clock divider 1 the oscillator clock is divided by 8 before feeding into the flash clock divider 5? fdiv[5:0] clock divider bits ?the combination of prdiv8 and fdiv[5:0] must divide the oscillator clock down to a frequency of 150 khz ?200 khz. the maximum divide ratio is 512. refer to section 19.4.1.1, ?riting the fclkdiv register for more information. module base + 0x0001 76543210 r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w reset f f ffffff = unimplemented or reserved figure 19-5. flash security register (fsec)
chapter 19 96 kbyte flash module (s12fts96kv1) 538 mc9s12q128 freescale semiconductor rev 1.09 the security function in the flash module is described in section 19.4.3, ?lash module security . 19.3.2.3 reserved1 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. table 19-4. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits ?the keyen[1:0] bits de?e the enabling of the backdoor key access to the flash module as shown in table 19-5 . 5? nv[5:2] nonvolatile flag bits ?the nv[5:2] bits are available to the user as nonvolatile ?gs. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 19-6 . if the flash module is unsecured using backdoor key access, the sec[1:0] bits are forced to 1:0. table 19-5. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 (1) 1. preferred keyen state to disable backdoor key access. disabled 10 enabled 11 disabled table 19-6. flash security states sec[1:0] status of security 00 secured 01 (1) 1. preferred sec state to set mcu to secured state. secured 10 unsecured 11 secured module base + 0x0002 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 19-6. reserved1
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 539 rev 1.09 19.3.2.4 flash con?uration register (fcnfg) the fcnfg register enables the flash interrupts and gates the security backdoor key writes. cbeie, ccie, and keyacc are readable and writable while remaining bits read 0 and are not writable. keyacc is only writable if the keyen bit in the fsec register is set to the enabled state (see section 19.3.2.2 ). 19.3.2.5 flash protection register (fprot) the fprot register de?es which flash sectors are protected against program or erase. the fprot register is readable in normal and special modes. fpopen can only be written from a 1 to a 0. fpls[1:0] can be written anytime until fpldis is cleared. fphs[1:0] can be written anytime until module base + 0x0003 76543210 r cbeie ccie keyacc 00000 w reset 00000000 = unimplemented or reserved figure 19-7. flash con?uration register (fcnfg) table 19-7. fcnfg field descriptions field description 7 cbeie command buffer empty interrupt enable ?the cbeie bit enables the interrupts in case of an empty command buffer in the flash module. 0 command buffer empty interrupts disabled 1 an interrupt will be requested whenever the cbeif ?g is set (see section 19.3.2.6 ) 6 ccie command complete interrupt enable ?the ccie bit enables the interrupts in case of all commands being completed in the flash module. 0 command complete interrupts disabled 1 an interrupt will be requested whenever the ccif ?g is set (see section 19.3.2.6 ) 5 keyacc enable security key writing . 0 flash writes are interpreted as the start of a command write sequence 1 writes to the flash array are interpreted as a backdoor key while reads of the flash array return invalid data module base + 0x0004 76543210 r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w reset f f ffffff figure 19-8. flash protection register (fprot)
chapter 19 96 kbyte flash module (s12fts96kv1) 540 mc9s12q128 freescale semiconductor rev 1.09 fphdis is cleared. the fprot register is loaded from flash address 0xff0d during the reset sequence, indicated by f in figure 19-8 . to change the flash protection that will be loaded on reset, the upper sector of the flash array must be unprotected, then the flash protection byte located at flash address 0xff0d must be written to. a protected flash sector is disabled by fphdis and fpldis while the size of the protected sector is de?ed by fphs[1:0] and fpls[1:0] in the fprot register. trying to alter any of the protected areas will result in a protect violation error and the pviol ?g will be set in the fstat register (see section 19.3.2.6 ). a mass erase of the whole flash array is only possible when protection is fully disabled by setting the fpopen , fpldis, and fphdis bits. an attempt to mass erase a flash array while protection is enabled will set the pviol ?g in the fstat register. table 19-8. fprot field descriptions field description 7 fpopen protection function for program or erase ?it is possible using the fpopen bit to either select address ranges to be protected using fphdis, fpldis, fphs[1:0] and fpls[1:0] or to select the same ranges to be unprotected. when fpopen is set, fpxdis enables the ranges to be protected, whereby clearing fpxdis enables protection for the range speci?d by the corresponding fpxs[1:0] bits. when fpopen is cleared, fpxdis de?es unprotected ranges as speci?d by the corresponding fpxs[1:0] bits. in this case, setting fpxdis enables protection. thus the effective polarity of the fpxdis bits is swapped by the fpopen bit as shown in table 19-9 . this function allows the main part of the flash array to be protected while a small range can remain unprotected for eeprom emulation. 0 the fphdis and fpldis bits de?e flash address ranges to be unprotected 1 the fphdis and fpldis bits de?e flash address ranges to be protected 6 nv6 nonvolatile flag bit ?the nv6 bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in the higher space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs[1:0] bits determine the size of the protected/unprotected sector as shown in table 19-10 . the fphs[1:0] bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected sector in the lower space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls[1:0] bits determine the size of the protected/unprotected sector as shown in table 19-11 . the fpls[1:0] bits can only be written to while the fpldis bit is set.
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 541 rev 1.09 figure 19-9 illustrates all possible protection scenarios. although the protection scheme is loaded from the flash array after reset, it is allowed to change in normal modes. this protection scheme can be used by applications requiring re-programming in single chip mode while providing as much protection as possible if no re-programming is required. table 19-9. flash protection function fpopen fphdis fphs[1] fphs[0] fpldis fpls[1] fpls[0] function (1) 1. for range sizes refer to table 19-10 and table 19-11 or . 1 1 x x 1 x x no protection 1 1 x x 0 x x protect low range 1 0 x x 1 x x protect high range 1 0 x x 0 x x protect high and low ranges 0 1 x x 1 x x full flash array protected 0 0 x x 1 x x unprotected high range 0 1 x x 0 x x unprotected low range 0 0 x x 0 x x unprotected high and low ranges table 19-10. flash protection higher address range fphs[1:0] address range range size 00 0xf800?xffff 2 kbytes 01 0xf000?xffff 4 kbytes 10 0xe000?xffff 8 kbytes 11 0xc000?xffff 16 kbytes table 19-11. flash protection lower address range fpls[1:0] address range range size 00 0x4000?x43ff 1 kbyte 01 0x4000?x47ff 2 kbytes 10 0x4000?x4fff 4 kbytes 11 0x4000?x5fff 8 kbytes
chapter 19 96 kbyte flash module (s12fts96kv1) 542 mc9s12q128 freescale semiconductor rev 1.09 figure 19-9. flash protection scenarios 19.3.2.5.1 flash protection restrictions the general guideline is that protection can only be added, not removed. all valid transitions between flash protection scenarios are speci?d in table 19-12 . any attempt to write an invalid scenario to the fprot register will be ignored and the fprot register will remain unchanged. the contents of the fprot register re?ct the active protection scenario. table 19-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567 0 xxxx 1xx 2xx 3x 4xx 5 xxxx 7 6 5 4 fpopen = 1 3 2 1 0 fphs[1:0] fpls[1:0] fpopen = 0 fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario protected flash fphs[1:0] fpls[1:0] 0xffff 0xffff
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 543 rev 1.09 19.3.2.6 flash status register (fstat) the fstat register de?es the status of the flash command controller and the results of command execution. in normal modes, bits cbeif, pviol, and accerr are readable and writable, bits ccif and blank are readable and not writable, remaining bits, including fail and done, read 0 and are not writable. in special modes, fail is readable and writable while done is readable but not writable. fail must be clear in special modes when starting a command write sequence. 6xxxx 7 xxxxxxxx 1. allowed transitions marked with x. module base + 0x0005 76543210 r cbeif ccif pviol accerr 0 blank fail done w reset 11000001 = unimplemented or reserved figure 19-10. flash status register (fstat) table 19-13. fstat field descriptions field description 7 cbeif command buffer empty interrupt flag ?the cbeif ?g indicates that the address, data and command buffers are empty so that a new command write sequence can be started. the cbeif ?g is cleared by writing a 1 to cbeif. writing a 0 to the cbeif ?g has no effect on cbeif. writing a 0 to cbeif after writing an aligned word to the flash address space but before cbeif is cleared will abort a command write sequence and cause the accerr ?g in the fstat register to be set. writing a 0 to cbeif outside of a command write sequence will not set the accerr ?g. the cbeif ?g is used together with the cbeie bit in the fcnfg register to generate an interrupt request (see figure 19-26 ). 0 buffers are full 1 buffers are ready to accept a new command 6 ccif command complete interrupt flag the ccif ?g indicates that there are no more commands pending. the ccif ?g is cleared when cbeif is clear and sets automatically upon completion of all active and pending commands. the ccif ?g does not set when an active commands completes and a pending command is fetched from the command buffer. writing to the ccif ?g has no effect. the ccif ?g is used together with the ccie bit in the fcnfg register to generate an interrupt request (see figure 19-26 ). 0 command in progress 1 all commands are completed table 19-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567
chapter 19 96 kbyte flash module (s12fts96kv1) 544 mc9s12q128 freescale semiconductor rev 1.09 19.3.2.7 flash command register (fcmd) the fcmd register de?es the flash commands. bits cmdb6, cmdb5, cmdb2, and cmdb0 are readable and writable during a command write sequence while bits 7, 4, 3, and 1 read 0 and are not writable. 5 pviol protection violation ?the pviol ?g indicates an attempt was made to program or erase an address in a protected flash array memory area. the pviol ?g is cleared by writing a 1 to pviol. writing a 0 to the pviol ?g has no effect on pviol. while pviol is set, it is not possible to launch another command. 0 no protection violation detected 1 protection violation has occurred 4 accerr access error the accerr ?g indicates an illegal access to the flash array caused by either a violation of the command write sequence, issuing an illegal command (illegal combination of the cmdbx bits in the fcmd register) or the execution of a cpu stop instruction while a command is executing (ccif=0). the accerr ?g is cleared by writing a 1 to accerr. writing a 0 to the accerr ?g has no effect on accerr. while accerr is set, it is not possible to launch another command. 0 no access error detected 1 access error has occurred 2 blank flash array has been veri?d as erased ?the blank ?g indicates that an erase verify command has checked the flash array and found it to be erased. the blank ?g is cleared by hardware when cbeif is cleared as part of a new valid command write sequence. writing to the blank ?g has no effect on blank. 0 if an erase verify command has been requested, and the ccif ?g is set, then a 0 in blank indicates the array is not erased 1 flash array veri?s as erased 1 fail flag indicating a failed flash operation in special modes, the fail ?g will set if the erase verify operation fails (flash array veri?d as not erased). writing a 0 to the fail ?g has no effect on fail. the fail ?g is cleared by writing a 1 to fail. while fail is set, it is not possible to launch another command. 0 flash operation completed without error 1 flash operation failed 0 done flag indicating a failed operation is not active ?in special modes, the done ?g will clear if a program, erase, or erase verify operation is active. 0 flash operation is active 1 flash operation is not active module base + 0x0006 76543210 r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w reset 00000000 = unimplemented or reserved figure 19-11. flash command register (fcmd) table 19-13. fstat field descriptions field description
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 545 rev 1.09 19.3.2.8 reserved2 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 19.3.2.9 flash address register (faddr) faddrhi and faddrlo are the flash address registers. \ \ table 19-14. fcmd field descriptions field description 6, 5, 2, 0 cmdb[6:5] cmdb[2] cmdb[0] valid flash commands are shown in table 19-15 . an attempt to execute any command other than those listed in table 19-15 will set the accerr bit in the fstat register (see section 19.3.2.6 ). table 19-15. valid flash command list cmdb nvm command 0x05 erase verify 0x20 word program 0x40 sector erase 0x41 mass erase module base + 0x0007 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 19-12. reserved2 module base + 0x0008 76543210 r fabhi w reset 00000000 figure 19-13. flash address high register (faddrhi)
chapter 19 96 kbyte flash module (s12fts96kv1) 546 mc9s12q128 freescale semiconductor rev 1.09 in normal modes, all fabhi and fablo bits read 0 and are not writable. in special modes, the fabhi and fablo bits are readable and writable. for sector erase, the mcu address bits [9:0] are ignored .for mass erase, any address within the flash array is valid to start the command. 19.3.2.10 flash data register (fdata) fdatahi and fdatalo are the flash data registers. in normal modes, all fdatahi and fdatalo bits read 0 and are not writable. in special modes, all fdatahi and fdatalo bits are readable and writable when writing to an address within the flash address range. 19.3.2.11 reserved3 this register is reserved for factory testing and is not accessible to the user. module base + 0x0009 76543210 r fablo w reset 00000000 figure 19-14. flash address low register (faddrlo) module base + 0x000a 76543210 r fdhi w reset 00000000 figure 19-15. flash data high register (fdatahi) module base + 0x000b 76543210 r fdlo w reset 00000000 figure 19-16. flash data low register (fdatalo)
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 547 rev 1.09 all bits read 0 and are not writable. 19.3.2.12 reserved4 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 19.3.2.13 reserved5 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 19.3.2.14 reserved6 this register is reserved for factory testing and is not accessible to the user. module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 19-17. reserved3 module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 19-18. reserved4 module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 19-19. reserved5
chapter 19 96 kbyte flash module (s12fts96kv1) 548 mc9s12q128 freescale semiconductor rev 1.09 all bits read 0 and are not writable. 19.4 functional description 19.4.1 flash command operations write operations are used for the program, erase, and erase verify algorithms described in this section. the program and erase algorithms are controlled by a state machine whose timebase fclk is derived from the oscillator clock via a programmable divider. the fcmd register as well as the associated faddr and fdata registers operate as a buffer and a register (2-stage fifo) so that a new command along with the necessary data and address can be stored to the buffer while the previous command is still in progress. this pipelined operation allows a time optimization when programming more than one word on a speci? row, as the high voltage generation can be kept active in between two programming commands. the pipelined operation also allows a simpli?ation of command launching. buffer empty as well as command completion are signalled by ?gs in the fstat register with corresponding interrupts generated, if enabled. the next sections describe: how to write the fclkdiv register command write sequence used to program, erase or erase verify the flash array valid flash commands errors resulting from illegal flash operations 19.4.1.1 writing the fclkdiv register prior to issuing any flash command after a reset, it is ?st necessary to write the fclkdiv register to divide the oscillator clock down to within the 150-khz to 200-khz range. since the program and erase timings are also a function of the bus clock, the fclkdiv determination must take this information into account. if we de?e: fclk as the clock of the flash timing control block tbus as the period of the bus clock int(x) as taking the integer part of x (e.g., int(4.323) = 4), module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 19-20. reserved6
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 549 rev 1.09 then fclkdiv register bits prdiv8 and fdiv[5:0] are to be set as described in figure 19-21 . for example, if the oscillator clock frequency is 950 khz and the bus clock is 10 mhz, fclkdiv bits fdiv[5:0] should be set to 4 (000100) and bit prdiv8 set to 0. the resulting fclk is then 190 khz. as a result, the flash algorithm timings are increased over optimum target by: command execution time will increase proportionally with the period of fclk. caution because of the impact of clock synchronization on the accuracy of the functional timings, programming or erasing the flash array cannot be performed if the bus clock runs at less than 1 mhz. programming or erasing the flash array with an input clock < 150 khz should be avoided. setting fclkdiv to a value such that fclk < 150 khz can destroy the flash array due to overstress. setting fclkdiv to a value such that (1/fclk + tbus) < 5 s can result in incomplete programming or erasure of the flash array cells. if the fclkdiv register is written, the bit fdivld is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written to, the flash command loaded during a command write sequence will not execute and the accerr ?g in the fstat register will set. 200 190 () 200 ? 100 5% =
chapter 19 96 kbyte flash module (s12fts96kv1) 550 mc9s12q128 freescale semiconductor rev 1.09 figure 19-21. prdiv8 and fdiv bits determination procedure prdiv8=1 yes no prdiv8=0 (reset) 12.8mhz? fclk=(prdclk)/(1+fdiv[5:0]) prdclk=oscillator_clock prdclk=oscillator_clock/8 prdclk[mhz]*(5+tbus[ s]) no fdiv[5:0]=prdclk[mhz]*(5+tbus[ s])-1 yes start tbus < 1 s? an integer? fdiv[5:0]=int(prdclk[mhz]*(5+tbus[ s])) 1/fclk[mhz] + tbus[ s] > 5 and fclk > 0.15mhz ? end yes no fdiv[5:0] > 4? all commands impossible yes no all commands impossible no try to decrease tbus yes oscillator_clock
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 551 rev 1.09 19.4.1.2 command write sequence the flash command controller is used to supervise the command write sequence to execute program, erase, and erase verify algorithms. before starting a command write sequence, the accerr and pviol ?gs in the fstat register must be clear and the cbeif ?g should be tested to determine the state of the address, data, and command buffers. if the cbeif ?g is set, indicating the buffers are empty, a new command write sequence can be started. if the cbeif ?g is clear, indicating the buffers are not available, a new command write sequence will overwrite the contents of the address, data, and command buffers. a command write sequence consists of three steps which must be strictly adhered to with writes to the flash module not permitted between the steps. however, flash register and array reads are allowed during a command write sequence. the basic command write sequence is as follows: 1. write to a valid address in the flash array memory. 2. write a valid command to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the command. the address written in step 1 will be stored in the faddr registers and the data will be stored in the fdata registers. when the cbeif ?g is cleared in step 3, the ccif ?g is cleared by the flash command controller indicating that the command was successfully launched. for all command write sequences, the cbeif ?g will set after the ccif ?g is cleared indicating that the address, data, and command buffers are ready for a new command write sequence to begin. a buffered command will wait for the active operation to be completed before being launched. once a command is launched, the completion of the command operation is indicated by the setting of the ccif ?g in the fstat register. the ccif ?g will set upon completion of all active and buffered commands.
chapter 19 96 kbyte flash module (s12fts96kv1) 552 mc9s12q128 freescale semiconductor rev 1.09 19.4.1.3 valid flash commands table 19-16 summarizes the valid flash commands along with the effects of the commands on the flash array. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. table 19-16. valid flash commands fcmd meaning function on flash array 0x05 erase verify verify all bytes in the flash array are erased. if the flash array is erased, the blank bit will set in the fstat register upon command completion. 0x20 program program a word (2 bytes) in the flash array. 0x40 sector erase erase all 1024 bytes in a sector of the flash array. 0x41 mass erase erase all bytes in the flash array. a mass erase of the full flash array is only possible when fpldis, fphdis , and fpopen bits in the fprot register are set prior to launching the command.
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 553 rev 1.09 19.4.1.3.1 erase verify command the erase verify operation will verify that a flash array is erased. an example ?w to execute the erase verify operation is shown in figure 19-22 . the erase verify command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the erase verify command. the address and data written will be ignored. 2. write the erase verify command, 0x05, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the erase verify command. after launching the erase verify command, the ccif ?g in the fstat register will set after the operation has completed unless a new command write sequence has been buffered. upon completion of the erase verify operation, the blank ?g in the fstat register will be set if all addresses in the flash array are veri?d to be erased. if any address in the flash array is not erased, the erase verify operation will terminate and the blank ?g in the fstat register will remain clear.
chapter 19 96 kbyte flash module (s12fts96kv1) 554 mc9s12q128 freescale semiconductor rev 1.09 figure 19-22. example erase verify command flow write: flash array address write: fcmd register erase verify command 0x05 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and dummy data bit polling for command completion check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check ccif set? accerr/ pviol set? no erase verify status yes exit flash array not erased exit flash array erased blank set? write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset.
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 555 rev 1.09 19.4.1.3.2 program command the program operation will program a previously erased word in the flash array using an embedded algorithm. an example ?w to execute the program operation is shown in figure 19-23 . the program command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the program command. the data written will be programmed to the flash array address written. 2. write the program command, 0x20, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the program command. if a word to be programmed is in a protected area of the flash array, the pviol ?g in the fstat register will set and the program command will not launch. once the program command has successfully launched, the ccif ?g in the fstat register will set after the program operation has completed unless a new command write sequence has been buffered. by executing a new program command write sequence on sequential words after the cbeif ?g in the fstat register has been set, up to 55% faster programming time per word can be effectively achieved than by waiting for the ccif ?g to set after each program operation.
chapter 19 96 kbyte flash module (s12fts96kv1) 556 mc9s12q128 freescale semiconductor rev 1.09 figure 19-23. example program command flow write: flash address write: fcmd register program command 0x20 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and program data bit polling for buffer empty check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check cbeif set? accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no yes sequential programming decision next word? no bit polling for command completion check read: fstat register yes ccif set?
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 557 rev 1.09 19.4.1.3.3 sector erase command the sector erase operation will erase all addresses in a 1024 byte sector of the flash array using an embedded algorithm. an example ?w to execute the sector erase operation is shown in figure 19-24 . the sector erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the sector erase command. the flash address written determines the sector to be erased while mcu address bits [9:0] and the data written are ignored. 2. write the sector erase command, 0x40, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the sector erase command. if a flash sector to be erased is in a protected area of the flash array, the pviol ?g in the fstat register will set and the sector erase command will not launch. once the sector erase command has successfully launched, the ccif ?g in the fstat register will set after the sector erase operation has completed unless a new command write sequence has been buffered.
chapter 19 96 kbyte flash module (s12fts96kv1) 558 mc9s12q128 freescale semiconductor rev 1.09 figure 19-24. example sector erase command flow write: flash sector address write: fcmd register sector erase command 0x40 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 559 rev 1.09 19.4.1.3.4 mass erase command the mass erase operation will erase all addresses in a flash array using an embedded algorithm. an example ?w to execute the mass erase operation is shown in figure 19-25 . the mass erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the mass erase command. the address and data written will be ignored. 2. write the mass erase command, 0x41, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the mass erase command. if a flash array to be erased contains any protected area, the pviol ?g in the fstat register will set and the mass erase command will not launch. once the mass erase command has successfully launched, the ccif ?g in the fstat register will set after the mass erase operation has completed unless a new command write sequence has been buffered.
chapter 19 96 kbyte flash module (s12fts96kv1) 560 mc9s12q128 freescale semiconductor rev 1.09 figure 19-25. example mass erase command flow write: flash block address write: fcmd register mass erase command 0x41 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 561 rev 1.09 19.4.1.4 illegal flash operations 19.4.1.4.1 access error the accerr ?g in the fstat register will be set during the command write sequence if any of the following illegal flash operations are performed causing the command write sequence to immediately abort: 1. writing to the flash address space before initializing the fclkdiv register 2. writing a misaligned word or a byte to the valid flash address space 3. writing to the flash address space while cbeif is not set 4. writing a second word to the flash address space before executing a program or erase command on the previously written word 5. writing to any flash register other than fcmd after writing a word to the flash address space 6. writing a second command to the fcmd register before executing the previously written command 7. writing an invalid command to the fcmd register 8. writing to any flash register other than fstat (to clear cbeif) after writing to the fcmd register 9. the part enters stop mode and a program or erase command is in progress. the command is aborted and any pending command is killed 10. when security is enabled, a command other than mass erase originating from a non-secure memory or from the background debug mode is written to the fcmd register 11. a 0 is written to the cbeif bit in the fstat register to abort a command write sequence. the accerr ?g will not be set if any flash register is read during the command write sequence. if the flash array is read during execution of an algorithm (ccif=0), the flash module will return invalid data and the accerr ?g will not be set. if an accerr ?g is set in the fstat register, the flash command controller is locked. it is not possible to launch another command until the accerr ?g is cleared. 19.4.1.4.2 protection violation the pviol ?g in the fstat register will be set during the command write sequence after the word write to the flash address space if any of the following illegal flash operations are performed, causing the command write sequence to immediately abort: 1. writing a flash address to program in a protected area of the flash array (see section 19.3.2.5 ). 2. writing a flash address to erase in a protected area of the flash array. 3. writing the mass erase command to the fcmd register while any protection is enabled. if the pviol ?g is set, the flash command controller is locked. it is not possible to launch another command until the pviol ?g is cleared.
chapter 19 96 kbyte flash module (s12fts96kv1) 562 mc9s12q128 freescale semiconductor rev 1.09 19.4.2 operating modes 19.4.2.1 wait mode if the mcu enters wait mode while a flash command is active (ccif = 0), that command and any buffered command will be completed. the flash module can recover the mcu from wait mode if the interrupts are enabled (see section 19.4.5 ). 19.4.2.2 stop mode if the mcu enters stop mode while a flash command is active (ccif = 0), that command will be aborted and the data being programmed or erased is lost. the high voltage circuitry to the flash array will be switched off when entering stop mode. ccif and accerr ?gs will be set. upon exit from stop mode, the cbeif ?g will be set and any buffered command will not be executed. the accerr ?g must be cleared before returning to normal operation. note as active flash commands are immediately aborted when the mcu enters stop mode, it is strongly recommended that the user does not use the stop instruction during program and erase execution. 19.4.2.3 background debug mode in background debug mode (bdm), the fprot register is writable. if the mcu is unsecured, then all flash commands listed in table 19-16 can be executed. if the mcu is secured and is in special single chip mode, the only possible command to execute is mass erase. 19.4.3 flash module security the flash module provides the necessary security information to the mcu. after each reset, the flash module determines the security state of the mcu as de?ed in section 19.3.2.2, ?lash security register (fsec) . the contents of the flash security/options byte at address 0xff0f in the flash con?uration ?ld must be changed directly by programming address 0xff0f when the device is unsecured and the higher address sector is unprotected. if the flash security/options byte is left in the secure state, any reset will cause the mcu to return to the secure operating mode. 19.4.3.1 unsecuring the mcu using backdoor key access the mcu may only be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor key (four 16-bit words programmed at addresses 0xff00?xff07). if keyen[1:0] = 1:0 and the keyacc bit is set, a write to a backdoor key address in the flash array triggers a comparison between the written data and the backdoor key data stored in the flash array. if all four words of data are written to the correct addresses in the correct order and the data matches the backdoor key stored in the flash array, the mcu will be unsecured. the data must be written to the backdoor key
chapter 19 96 kbyte flash module (s12fts96kv1) freescale semiconductor mc9s12q128 563 rev 1.09 addresses sequentially staring with 0xff00-0xff01 and ending with 0xff06?xff07. the values 0x0000 and 0xffff are not permitted as keys. when the keyacc bit is set, reads of the flash array will return invalid data. the user code stored in the flash array must have a method of receiving the backdoor key from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if keyen[1:0] = 1:0 in the fsec register, the mcu can be unsecured by the backdoor key access sequence described below: 1. set the keyacc bit in the fcnfg register 2. write the correct four 16-bit words to flash addresses 0xff00?xff07 sequentially starting with 0xff00 3. clear the keyacc bit in the fcnfg register 4. if all four 16-bit words match the backdoor key stored in flash addresses 0xff00?xff07, the mcu is unsecured and bits sec[1:0] in the fsec register are forced to the unsecure state of 1:0 the backdoor key access sequence is monitored by the internal security state machine. an illegal operation during the backdoor key access sequence will cause the security state machine to lock, leaving the mcu in the secured state. a reset of the mcu will cause the security state machine to exit the lock state and allow a new backdoor key access sequence to be attempted. the following illegal operations will lock the security state machine: 1. if any of the four 16-bit words does not match the backdoor key programmed in the flash array 2. if the four 16-bit words are written in the wrong sequence 3. if more than four 16-bit words are written 4. if any of the four 16-bit words written are 0x0000 or 0xffff 5. if the keyacc bit does not remain set while the four 16-bit words are written after the backdoor key access sequence has been correctly matched, the mcu will be unsecured. the flash security byte can be programmed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the four word backdoor key by programming bytes 0xff00?xff07 of the flash con?uration ?ld. the security as de?ed in the flash security/options byte at address 0xff0f is not changed by using the backdoor key access sequence to unsecure. the backdoor key stored in addresses 0xff00?xff07 is unaffected by the backdoor key access sequence. after the next reset sequence, the security state of the flash module is determined by the flash security/options byte at address 0xff0f. the backdoor key access sequence has no effect on the program and erase protection de?ed in the fprot register. it is not possible to unsecure the mcu in special single chip mode by executing the backdoor key access sequence in background debug mode.
chapter 19 96 kbyte flash module (s12fts96kv1) 564 mc9s12q128 freescale semiconductor rev 1.09 19.4.4 flash reset sequence on each reset, the flash module executes a reset sequence to hold cpu activity while loading the following registers from the flash array memory according to table 19-1 : fprot ?flash protection register (see section 19.3.2.5 ) fsec ?flash security register (see section 19.3.2.2 ) 19.4.4.1 reset while flash command active if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/array being erased is not guaranteed. 19.4.5 interrupts the flash module can generate an interrupt when all flash commands have completed execution or the flash address, data, and command buffers are empty. note vector addresses and their relative interrupt priority are determined at the mcu level. 19.4.5.1 description of interrupt operation figure 19-26 shows the logic used for generating interrupts. the flash module uses the cbeif and ccif ?gs in combination with the enable bits cbie and ccie to discriminate for the generation of interrupts. figure 19-26. flash interrupt implementation for a detailed description of these register bits, refer to section 19.3.2.4, ?lash con?uration register (fcnfg) and section 19.3.2.6, ?lash status register (fstat) . table 19-17. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash address, data, and command buffers are empty cbeif (fstat register) cbeie i bit all flash commands have completed execution ccif (fstat register) ccie i bit cbeif cbeie ccif ccie flash interrupt request
freescale semiconductor mc9s12q128 565 rev 1.09 chapter 20 128 kbyte flash module (s12fts128k1v1) 20.1 introduction the fts128k1 module implements a 128 kbyte flash (nonvolatile) memory. the flash memory contains one array of 128 kbytes organized as 1024 rows of 128 bytes with an erase sector size of eight rows ( 1024 bytes). the flash array may be read as either bytes, aligned words, or misaligned words. read access time is one bus cycle for byte and aligned word, and two bus cycles for misaligned words. the flash array is ideal for program and data storage for single-supply applications allowing for ?ld reprogramming without requiring external voltage sources for program or erase. program and erase functions are controlled by a command driven interface. the flash module supports both mass erase and sector erase. an erased bit reads 1 and a programmed bit reads 0. the high voltage required to program and erase is generated internally. it is not possible to read from a flash array while it is being erased or programmed. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. 20.1.1 glossary command write sequence a three-step mcu instruction sequence to program, erase, or erase verify the flash array memory. 20.1.2 features 128 kbytes of flash memory comprised of one 128 kbyte array divided into 128 sectors of 1024 bytes automated program and erase algorithm interrupts on flash command completion and command buffer empty fast sector erase and word program operation 2-stage command pipeline for faster multi-word program times flexible protection scheme to prevent accidental program or erase single power supply for flash program and erase operations security feature to prevent unauthorized access to the flash array memory
chapter 20 128 kbyte flash module (s12fts128k1v1) 566 mc9s12q128 freescale semiconductor rev 1.09 20.1.3 modes of operation see section 20.4.2, ?perating modes ?for a description of the flash module operating modes. for program and erase operations, refer to section 20.4.1, ?lash command operations . 20.1.4 block diagram figure 20-1 shows a block diagram of the fts128k1 module. figure 20-1. fts128k1 block diagram 20.2 external signal description the fts128k1 module contains no signals that connect off-chip. fts128k1 oscillator clock command complete interrupt command buffer empty interrupt flash array 64k * 16 bits sector 0 sector 1 sector 127 clock divider fclk protection security command pipeline cmd2 addr2 data2 cmd1 addr1 data1 registers flash interface
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 567 rev 1.09 20.3 memory map and registers this section describes the fts128k1 memory map and registers. 20.3.1 module memory map the fts128k1 memory map is shown in figure 20-2 . the hcs12 architecture places the flash array addresses between 0x4000 and 0xffff , which corresponds to three 16 kbyte pages . the content of the hcs12 core ppage register is used to map the logical middle page ranging from address 0x8000 to 0xbfff to a ny physical 16k byte page in the flash array memory. 1 the fprot register (see section 20.3.2.5 ) can be set to globally protect the entire flash array . three separate areas, one starting from the flash array starting address (called lower) towards higher addresses, one growing downward from the flash array end address (called higher), and the remaining addresses, can be activated for protection . the flash array addresses covered by these protectable regions are shown in figure 20-2. the higher address area is mainly targeted to hold the boot loader code since it covers the vector space. the lower address area can be used for eeprom emulation in an mcu without an eeprom module since it can be left unprotected while the remaining addresses are protected from program or erase. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld described in table 20-1 . 1. by placing 0x3e/ 0x3f in the hcs12 core ppage register, the bottom/top ?ed 16 kbyte page s can be seen twice in the mcu memory map. table 20-1. flash con?uration field flash address size (bytes) description 0xff00?xff07 8 backdoor key to unlock security 0xff08?xff0c 5 reserved 0xff0d 1 flash protection byte refer to section 20.3.2.5, ?lash protection register (fprot) 0xff0e 1 reserved 0xff0f 1 flash security/options byte refer to section 20.3.2.2, ?lash security register (fsec)
chapter 20 128 kbyte flash module (s12fts128k1v1) 568 mc9s12q128 freescale semiconductor rev 1.09 figure 20-2. flash memory map flash registers module base + 0x0000 0xff00?xff0f (flash con?uration field) module base + 0x000f 0x8000 flash protected low sectors 1, 2, 4, 8 kbytes flash_start = 0x4000 0x5000 0x4400 0x6000 16k paged memory 0x38 0x39 0x3a 0x3b 0x3e 0x3c 0x3d 003e 0x3f note: 0x38?x3f correspond to the ppage register content flash_end = 0xffff 0xf800 0xf000 0xc000 0xe000 flash protected high sectors 2, 4, 8, 16 kbytes 0x3f 0x4800 flash array 16 bytes
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 569 rev 1.09 table 20-2. flash array memory map summary mcu address range ppage protectable low range protectable high range array relative address (1) 1. inside flash block. 0x0000?x3fff (2) 2. if allowed by mcu. unpaged (0x3d) n.a. n.a. 0x14000?x17fff 0x4000?x7fff unpaged (0x3e) 0x4000?x43ff n.a. 0x18000?x1bfff 0x4000?x47ff 0x4000?x4fff 0x4000?x5fff 0x8000?xbfff 0x38 n.a. n.a. 0x00000?x03fff 0x39 n.a. n.a. 0x04000?x07fff 0x3a n.a. n.a. 0x08000?x0bfff 0x3b n.a. n.a. 0x0c000?x0ffff 0x3c n.a. n.a. 0x10000?x13fff 0x3d n.a. n.a. 0x14000?x17fff 0x3e 0x8000?x83ff n.a. 0x18000?x1bfff 0x8000?x87ff 0x8000?x8fff 0x8000?x9fff 0x3f n.a. 0xb800?xbfff 0x1c000?x1ffff 0xb000?xbfff 0xa000?xbfff 0x8000?xbfff 0xc000?xffff unpaged (0x3f) n.a. 0xf800?xffff 0x1c000?x1ffff 0xf000?xffff 0xe000?xffff 0xc000?xffff
chapter 20 128 kbyte flash module (s12fts128k1v1) 570 mc9s12q128 freescale semiconductor rev 1.09 20.3.2 register descriptions the flash module contains a set of 16 control and status registers located between module base + 0x0000 and 0x000f. a summary of the flash module registers is given in figure 20-3 . detailed descriptions of each register bit are provided. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 fclkdiv r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w 0x0002 reserved1 (1) 1. intended for factory test purposes only. r00000000 w 0x0003 fcnfg r cbeie ccie keyacc 00000 w 0x0004 fprot r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0005 fstat r cbeif ccif pviol accerr 0 blank fail done w 0x0006 fcmd r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w 0x0007 reserved2 1 r00000000 w 0x0008 faddrhi 1 r fabhi w 0x0009 faddrlo 1 r fablo w 0x000a fdatahi 1 r fdhi w 0x000b fdatalo 1 r fdlo w 0x000c reserved3 1 r00000000 w 0x000d reserved4 1 r00000000 w 0x000e reserved5 1 r00000000 w 0x000f reserved6 1 r00000000 w = unimplemented or reserved figure 20-3. flash register summary
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 571 rev 1.09 20.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bits 6? are write once and bit 7 is not writable. 20.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. the fsec register is loaded from the flash con?uration ?ld at 0xff0f during the reset sequence, indicated by f in figure 20-5 . module base + 0x0000 76543210 r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w reset 00000000 = unimplemented or reserved figure 20-4. flash clock divider register (fclkdiv) table 20-3. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written 1 fclkdiv register has been written to since the last reset 6 prdiv8 enable prescalar by 8 0 the oscillator clock is directly fed into the flash clock divider 1 the oscillator clock is divided by 8 before feeding into the flash clock divider 5? fdiv[5:0] clock divider bits ?the combination of prdiv8 and fdiv[5:0] must divide the oscillator clock down to a frequency of 150 khz ?200 khz. the maximum divide ratio is 512. refer to section 20.4.1.1, ?riting the fclkdiv register for more information. module base + 0x0001 76543210 r keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 w reset f f ffffff = unimplemented or reserved figure 20-5. flash security register (fsec)
chapter 20 128 kbyte flash module (s12fts128k1v1) 572 mc9s12q128 freescale semiconductor rev 1.09 the security function in the flash module is described in section 20.4.3, ?lash module security . 20.3.2.3 reserved1 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. table 20-4. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits ?the keyen[1:0] bits de?e the enabling of the backdoor key access to the flash module as shown in table 20-5 . 5? nv[5:2] nonvolatile flag bits ?the nv[5:2] bits are available to the user as nonvolatile ?gs. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 20-6 . if the flash module is unsecured using backdoor key access, the sec[1:0] bits are forced to 1:0. table 20-5. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 (1) 1. preferred keyen state to disable backdoor key access. disabled 10 enabled 11 disabled table 20-6. flash security states sec[1:0] status of security 00 secured 01 (1) 1. preferred sec state to set mcu to secured state. secured 10 unsecured 11 secured module base + 0x0002 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 20-6. reserved1
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 573 rev 1.09 20.3.2.4 flash con?uration register (fcnfg) the fcnfg register enables the flash interrupts and gates the security backdoor key writes. cbeie, ccie, and keyacc are readable and writable while remaining bits read 0 and are not writable. keyacc is only writable if the keyen bit in the fsec register is set to the enabled state (see section 20.3.2.2 ). 20.3.2.5 flash protection register (fprot) the fprot register de?es which flash sectors are protected against program or erase. the fprot register is readable in normal and special modes. fpopen can only be written from a 1 to a 0. fpls[1:0] can be written anytime until fpldis is cleared. fphs[1:0] can be written anytime until module base + 0x0003 76543210 r cbeie ccie keyacc 00000 w reset 00000000 = unimplemented or reserved figure 20-7. flash con?uration register (fcnfg) table 20-7. fcnfg field descriptions field description 7 cbeie command buffer empty interrupt enable ?the cbeie bit enables the interrupts in case of an empty command buffer in the flash module. 0 command buffer empty interrupts disabled 1 an interrupt will be requested whenever the cbeif ?g is set (see section 20.3.2.6 ) 6 ccie command complete interrupt enable ?the ccie bit enables the interrupts in case of all commands being completed in the flash module. 0 command complete interrupts disabled 1 an interrupt will be requested whenever the ccif ?g is set (see section 20.3.2.6 ) 5 keyacc enable security key writing . 0 flash writes are interpreted as the start of a command write sequence 1 writes to the flash array are interpreted as a backdoor key while reads of the flash array return invalid data module base + 0x0004 76543210 r fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w reset f f ffffff figure 20-8. flash protection register (fprot)
chapter 20 128 kbyte flash module (s12fts128k1v1) 574 mc9s12q128 freescale semiconductor rev 1.09 fphdis is cleared. the fprot register is loaded from flash address 0xff0d during the reset sequence, indicated by f in figure 20-8 . to change the flash protection that will be loaded on reset, the upper sector of the flash array must be unprotected, then the flash protection byte located at flash address 0xff0d must be written to. a protected flash sector is disabled by fphdis and fpldis while the size of the protected sector is de?ed by fphs[1:0] and fpls[1:0] in the fprot register. trying to alter any of the protected areas will result in a protect violation error and the pviol ?g will be set in the fstat register (see section 20.3.2.6 ). a mass erase of the whole flash array is only possible when protection is fully disabled by setting the fpopen , fpldis, and fphdis bits. an attempt to mass erase a flash array while protection is enabled will set the pviol ?g in the fstat register. table 20-8. fprot field descriptions field description 7 fpopen protection function for program or erase ?it is possible using the fpopen bit to either select address ranges to be protected using fphdis, fpldis, fphs[1:0] and fpls[1:0] or to select the same ranges to be unprotected. when fpopen is set, fpxdis enables the ranges to be protected, whereby clearing fpxdis enables protection for the range speci?d by the corresponding fpxs[1:0] bits. when fpopen is cleared, fpxdis de?es unprotected ranges as speci?d by the corresponding fpxs[1:0] bits. in this case, setting fpxdis enables protection. thus the effective polarity of the fpxdis bits is swapped by the fpopen bit as shown in table 20-9 . this function allows the main part of the flash array to be protected while a small range can remain unprotected for eeprom emulation. 0 the fphdis and fpldis bits de?e flash address ranges to be unprotected 1 the fphdis and fpldis bits de?e flash address ranges to be protected 6 nv6 nonvolatile flag bit ?the nv6 bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in the higher space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs[1:0] bits determine the size of the protected/unprotected sector as shown in table 20-10 . the fphs[1:0] bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected sector in the lower space of the flash address map. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls[1:0] bits determine the size of the protected/unprotected sector as shown in table 20-11 . the fpls[1:0] bits can only be written to while the fpldis bit is set.
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 575 rev 1.09 figure 20-9 illustrates all possible protection scenarios. although the protection scheme is loaded from the flash array after reset, it is allowed to change in normal modes. this protection scheme can be used by applications requiring re-programming in single chip mode while providing as much protection as possible if no re-programming is required. table 20-9. flash protection function fpopen fphdis fphs[1] fphs[0] fpldis fpls[1] fpls[0] function (1) 1. for range sizes refer to table 20-10 and table 20-11 or . 1 1 x x 1 x x no protection 1 1 x x 0 x x protect low range 1 0 x x 1 x x protect high range 1 0 x x 0 x x protect high and low ranges 0 1 x x 1 x x full flash array protected 0 0 x x 1 x x unprotected high range 0 1 x x 0 x x unprotected low range 0 0 x x 0 x x unprotected high and low ranges table 20-10. flash protection higher address range fphs[1:0] address range range size 00 0xf800?xffff 2 kbytes 01 0xf000?xffff 4 kbytes 10 0xe000?xffff 8 kbytes 11 0xc000?xffff 16 kbytes table 20-11. flash protection lower address range fpls[1:0] address range range size 00 0x4000?x43ff 1 kbyte 01 0x4000?x47ff 2 kbytes 10 0x4000?x4fff 4 kbytes 11 0x4000?x5fff 8 kbytes
chapter 20 128 kbyte flash module (s12fts128k1v1) 576 mc9s12q128 freescale semiconductor rev 1.09 figure 20-9. flash protection scenarios 20.3.2.5.1 flash protection restrictions the general guideline is that protection can only be added, not removed. all valid transitions between flash protection scenarios are speci?d in table 20-12 . any attempt to write an invalid scenario to the fprot register will be ignored and the fprot register will remain unchanged. the contents of the fprot register re?ct the active protection scenario. table 20-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567 0 xxxx 1xx 2xx 3x 4xx 5 xxxx 7 6 5 4 fpopen = 1 3 2 1 0 fphs[1:0] fpls[1:0] fpopen = 0 fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario protected flash fphs[1:0] fpls[1:0] 0xffff 0xffff
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 577 rev 1.09 20.3.2.6 flash status register (fstat) the fstat register de?es the status of the flash command controller and the results of command execution. in normal modes, bits cbeif, pviol, and accerr are readable and writable, bits ccif and blank are readable and not writable, remaining bits, including fail and done, read 0 and are not writable. in special modes, fail is readable and writable while done is readable but not writable. fail must be clear in special modes when starting a command write sequence. 6xxxx 7 xxxxxxxx 1. allowed transitions marked with x. module base + 0x0005 76543210 r cbeif ccif pviol accerr 0 blank fail done w reset 11000001 = unimplemented or reserved figure 20-10. flash status register (fstat) table 20-13. fstat field descriptions field description 7 cbeif command buffer empty interrupt flag ?the cbeif ?g indicates that the address, data and command buffers are empty so that a new command write sequence can be started. the cbeif ?g is cleared by writing a 1 to cbeif. writing a 0 to the cbeif ?g has no effect on cbeif. writing a 0 to cbeif after writing an aligned word to the flash address space but before cbeif is cleared will abort a command write sequence and cause the accerr ?g in the fstat register to be set. writing a 0 to cbeif outside of a command write sequence will not set the accerr ?g. the cbeif ?g is used together with the cbeie bit in the fcnfg register to generate an interrupt request (see figure 20-26 ). 0 buffers are full 1 buffers are ready to accept a new command 6 ccif command complete interrupt flag the ccif ?g indicates that there are no more commands pending. the ccif ?g is cleared when cbeif is clear and sets automatically upon completion of all active and pending commands. the ccif ?g does not set when an active commands completes and a pending command is fetched from the command buffer. writing to the ccif ?g has no effect. the ccif ?g is used together with the ccie bit in the fcnfg register to generate an interrupt request (see figure 20-26 ). 0 command in progress 1 all commands are completed table 20-12. flash protection scenario transitions from protection scenario to protection scenario (1) 01234567
chapter 20 128 kbyte flash module (s12fts128k1v1) 578 mc9s12q128 freescale semiconductor rev 1.09 20.3.2.7 flash command register (fcmd) the fcmd register de?es the flash commands. bits cmdb6, cmdb5, cmdb2, and cmdb0 are readable and writable during a command write sequence while bits 7, 4, 3, and 1 read 0 and are not writable. 5 pviol protection violation ?the pviol ?g indicates an attempt was made to program or erase an address in a protected flash array memory area. the pviol ?g is cleared by writing a 1 to pviol. writing a 0 to the pviol ?g has no effect on pviol. while pviol is set, it is not possible to launch another command. 0 no protection violation detected 1 protection violation has occurred 4 accerr access error the accerr ?g indicates an illegal access to the flash array caused by either a violation of the command write sequence, issuing an illegal command (illegal combination of the cmdbx bits in the fcmd register) or the execution of a cpu stop instruction while a command is executing (ccif=0). the accerr ?g is cleared by writing a 1 to accerr. writing a 0 to the accerr ?g has no effect on accerr. while accerr is set, it is not possible to launch another command. 0 no access error detected 1 access error has occurred 2 blank flash array has been veri?d as erased ?the blank ?g indicates that an erase verify command has checked the flash array and found it to be erased. the blank ?g is cleared by hardware when cbeif is cleared as part of a new valid command write sequence. writing to the blank ?g has no effect on blank. 0 if an erase verify command has been requested, and the ccif ?g is set, then a 0 in blank indicates the array is not erased 1 flash array veri?s as erased 1 fail flag indicating a failed flash operation in special modes, the fail ?g will set if the erase verify operation fails (flash array veri?d as not erased). writing a 0 to the fail ?g has no effect on fail. the fail ?g is cleared by writing a 1 to fail. while fail is set, it is not possible to launch another command. 0 flash operation completed without error 1 flash operation failed 0 done flag indicating a failed operation is not active ?in special modes, the done ?g will clear if a program, erase, or erase verify operation is active. 0 flash operation is active 1 flash operation is not active module base + 0x0006 76543210 r0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 w reset 00000000 = unimplemented or reserved figure 20-11. flash command register (fcmd) table 20-13. fstat field descriptions field description
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 579 rev 1.09 20.3.2.8 reserved2 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 20.3.2.9 flash address register (faddr) faddrhi and faddrlo are the flash address registers. \ \ \ table 20-14. fcmd field descriptions field description 6, 5, 2, 0 cmdb[6:5] cmdb[2] cmdb[0] valid flash commands are shown in table 20-15 . an attempt to execute any command other than those listed in table 20-15 will set the accerr bit in the fstat register (see section 20.3.2.6 ). table 20-15. valid flash command list cmdb nvm command 0x05 erase verify 0x20 word program 0x40 sector erase 0x41 mass erase module base + 0x0007 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 20-12. reserved2 module base + 0x0008 76543210 r fabhi w reset 00000000 figure 20-13. flash address high register (faddrhi)
chapter 20 128 kbyte flash module (s12fts128k1v1) 580 mc9s12q128 freescale semiconductor rev 1.09 in normal modes, all fabhi and fablo bits read 0 and are not writable. in special modes, the fabhi and fablo bits are readable and writable. for sector erase, the mcu address bits [9:0] are ignored .for mass erase, any address within the flash array is valid to start the command. 20.3.2.10 flash data register (fdata) fdatahi and fdatalo are the flash data registers. in normal modes, all fdatahi and fdatalo bits read 0 and are not writable. in special modes, all fdatahi and fdatalo bits are readable and writable when writing to an address within the flash address range. 20.3.2.11 reserved3 this register is reserved for factory testing and is not accessible to the user. module base + 0x0009 76543210 r fablo w reset 00000000 figure 20-14. flash address low register (faddrlo) module base + 0x000a 76543210 r fdhi w reset 00000000 figure 20-15. flash data high register (fdatahi) module base + 0x000b 76543210 r fdlo w reset 00000000 figure 20-16. flash data low register (fdatalo)
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 581 rev 1.09 all bits read 0 and are not writable. 20.3.2.12 reserved4 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 20.3.2.13 reserved5 this register is reserved for factory testing and is not accessible to the user. all bits read 0 and are not writable. 20.3.2.14 reserved6 this register is reserved for factory testing and is not accessible to the user. module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 20-17. reserved3 module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 20-18. reserved4 module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 20-19. reserved5
chapter 20 128 kbyte flash module (s12fts128k1v1) 582 mc9s12q128 freescale semiconductor rev 1.09 all bits read 0 and are not writable. 20.4 functional description 20.4.1 flash command operations write operations are used for the program, erase, and erase verify algorithms described in this section. the program and erase algorithms are controlled by a state machine whose timebase fclk is derived from the oscillator clock via a programmable divider. the fcmd register as well as the associated faddr and fdata registers operate as a buffer and a register (2-stage fifo) so that a new command along with the necessary data and address can be stored to the buffer while the previous command is still in progress. this pipelined operation allows a time optimization when programming more than one word on a speci? row, as the high voltage generation can be kept active in between two programming commands. the pipelined operation also allows a simpli?ation of command launching. buffer empty as well as command completion are signalled by ?gs in the fstat register with corresponding interrupts generated, if enabled. the next sections describe: how to write the fclkdiv register command write sequence used to program, erase or erase verify the flash array valid flash commands errors resulting from illegal flash operations 20.4.1.1 writing the fclkdiv register prior to issuing any flash command after a reset, it is ?st necessary to write the fclkdiv register to divide the oscillator clock down to within the 150-khz to 200-khz range. since the program and erase timings are also a function of the bus clock, the fclkdiv determination must take this information into account. if we de?e: fclk as the clock of the flash timing control block tbus as the period of the bus clock int(x) as taking the integer part of x (e.g., int(4.323) = 4), module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 20-20. reserved6
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 583 rev 1.09 then fclkdiv register bits prdiv8 and fdiv[5:0] are to be set as described in figure 20-21 . for example, if the oscillator clock frequency is 950 khz and the bus clock is 10 mhz, fclkdiv bits fdiv[5:0] should be set to 4 (000100) and bit prdiv8 set to 0. the resulting fclk is then 190 khz. as a result, the flash algorithm timings are increased over optimum target by: command execution time will increase proportionally with the period of fclk. caution because of the impact of clock synchronization on the accuracy of the functional timings, programming or erasing the flash array cannot be performed if the bus clock runs at less than 1 mhz. programming or erasing the flash array with an input clock < 150 khz should be avoided. setting fclkdiv to a value such that fclk < 150 khz can destroy the flash array due to overstress. setting fclkdiv to a value such that (1/fclk + tbus) < 5 s can result in incomplete programming or erasure of the flash array cells. if the fclkdiv register is written, the bit fdivld is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written to, the flash command loaded during a command write sequence will not execute and the accerr ?g in the fstat register will set. 200 190 () 200 ? 100 5% =
chapter 20 128 kbyte flash module (s12fts128k1v1) 584 mc9s12q128 freescale semiconductor rev 1.09 figure 20-21. prdiv8 and fdiv bits determination procedure prdiv8=1 yes no prdiv8=0 (reset) 12.8mhz? fclk=(prdclk)/(1+fdiv[5:0]) prdclk=oscillator_clock prdclk=oscillator_clock/8 prdclk[mhz]*(5+tbus[ s]) no fdiv[5:0]=prdclk[mhz]*(5+tbus[ s])-1 yes start tbus < 1 s? an integer? fdiv[5:0]=int(prdclk[mhz]*(5+tbus[ s])) 1/fclk[mhz] + tbus[ s] > 5 and fclk > 0.15mhz ? end yes no fdiv[5:0] > 4? all commands impossible yes no all commands impossible no try to decrease tbus yes oscillator_clock
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 585 rev 1.09 20.4.1.2 command write sequence the flash command controller is used to supervise the command write sequence to execute program, erase, and erase verify algorithms. before starting a command write sequence, the accerr and pviol ?gs in the fstat register must be clear and the cbeif ?g should be tested to determine the state of the address, data, and command buffers. if the cbeif ?g is set, indicating the buffers are empty, a new command write sequence can be started. if the cbeif ?g is clear, indicating the buffers are not available, a new command write sequence will overwrite the contents of the address, data, and command buffers. a command write sequence consists of three steps which must be strictly adhered to with writes to the flash module not permitted between the steps. however, flash register and array reads are allowed during a command write sequence. the basic command write sequence is as follows: 1. write to a valid address in the flash array memory. 2. write a valid command to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the command. the address written in step 1 will be stored in the faddr registers and the data will be stored in the fdata registers. when the cbeif ?g is cleared in step 3, the ccif ?g is cleared by the flash command controller indicating that the command was successfully launched. for all command write sequences, the cbeif ?g will set after the ccif ?g is cleared indicating that the address, data, and command buffers are ready for a new command write sequence to begin. a buffered command will wait for the active operation to be completed before being launched. once a command is launched, the completion of the command operation is indicated by the setting of the ccif ?g in the fstat register. the ccif ?g will set upon completion of all active and buffered commands.
chapter 20 128 kbyte flash module (s12fts128k1v1) 586 mc9s12q128 freescale semiconductor rev 1.09 20.4.1.3 valid flash commands table 20-16 summarizes the valid flash commands along with the effects of the commands on the flash array. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. table 20-16. valid flash commands fcmd meaning function on flash array 0x05 erase verify verify all bytes in the flash array are erased. if the flash array is erased, the blank bit will set in the fstat register upon command completion. 0x20 program program a word (2 bytes) in the flash array. 0x40 sector erase erase all 1024 bytes in a sector of the flash array. 0x41 mass erase erase all bytes in the flash array. a mass erase of the full flash array is only possible when fpldis, fphdis , and fpopen bits in the fprot register are set prior to launching the command.
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 587 rev 1.09 20.4.1.3.1 erase verify command the erase verify operation will verify that a flash array is erased. an example ?w to execute the erase verify operation is shown in figure 20-22 . the erase verify command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the erase verify command. the address and data written will be ignored. 2. write the erase verify command, 0x05, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the erase verify command. after launching the erase verify command, the ccif ?g in the fstat register will set after the operation has completed unless a new command write sequence has been buffered. upon completion of the erase verify operation, the blank ?g in the fstat register will be set if all addresses in the flash array are veri?d to be erased. if any address in the flash array is not erased, the erase verify operation will terminate and the blank ?g in the fstat register will remain clear.
chapter 20 128 kbyte flash module (s12fts128k1v1) 588 mc9s12q128 freescale semiconductor rev 1.09 figure 20-22. example erase verify command flow write: flash array address write: fcmd register erase verify command 0x05 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and dummy data bit polling for command completion check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check ccif set? accerr/ pviol set? no erase verify status yes exit flash array not erased exit flash array erased blank set? write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset.
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 589 rev 1.09 20.4.1.3.2 program command the program operation will program a previously erased word in the flash array using an embedded algorithm. an example ?w to execute the program operation is shown in figure 20-23 . the program command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the program command. the data written will be programmed to the flash array address written. 2. write the program command, 0x20, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the program command. if a word to be programmed is in a protected area of the flash array, the pviol ?g in the fstat register will set and the program command will not launch. once the program command has successfully launched, the ccif ?g in the fstat register will set after the program operation has completed unless a new command write sequence has been buffered. by executing a new program command write sequence on sequential words after the cbeif ?g in the fstat register has been set, up to 55% faster programming time per word can be effectively achieved than by waiting for the ccif ?g to set after each program operation.
chapter 20 128 kbyte flash module (s12fts128k1v1) 590 mc9s12q128 freescale semiconductor rev 1.09 figure 20-23. example program command flow write: flash address write: fcmd register program command 0x20 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation no and program data bit polling for buffer empty check read: fstat register yes read: fstat register no start yes check cbeif set? address, data, command buffer empty check cbeif set? accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no yes sequential programming decision next word? no bit polling for command completion check read: fstat register yes ccif set?
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 591 rev 1.09 20.4.1.3.3 sector erase command the sector erase operation will erase all addresses in a 1024 byte sector of the flash array using an embedded algorithm. an example ?w to execute the sector erase operation is shown in figure 20-24 . the sector erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the sector erase command. the flash address written determines the sector to be erased while mcu address bits [9:0] and the data written are ignored. 2. write the sector erase command, 0x40, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the sector erase command. if a flash sector to be erased is in a protected area of the flash array, the pviol ?g in the fstat register will set and the sector erase command will not launch. once the sector erase command has successfully launched, the ccif ?g in the fstat register will set after the sector erase operation has completed unless a new command write sequence has been buffered.
chapter 20 128 kbyte flash module (s12fts128k1v1) 592 mc9s12q128 freescale semiconductor rev 1.09 figure 20-24. example sector erase command flow write: flash sector address write: fcmd register sector erase command 0x40 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 593 rev 1.09 20.4.1.3.4 mass erase command the mass erase operation will erase all addresses in a flash array using an embedded algorithm. an example ?w to execute the mass erase operation is shown in figure 20-25 . the mass erase command write sequence is as follows: 1. write to a flash array address to start the command write sequence for the mass erase command. the address and data written will be ignored. 2. write the mass erase command, 0x41, to the fcmd register. 3. clear the cbeif ?g in the fstat register by writing a 1 to cbeif to launch the mass erase command. if a flash array to be erased contains any protected area, the pviol ?g in the fstat register will set and the mass erase command will not launch. once the mass erase command has successfully launched, the ccif ?g in the fstat register will set after the mass erase operation has completed unless a new command write sequence has been buffered.
chapter 20 128 kbyte flash module (s12fts128k1v1) 594 mc9s12q128 freescale semiconductor rev 1.09 figure 20-25. example mass erase command flow write: flash block address write: fcmd register mass erase command 0x41 write: fstat register clear cbeif 0x80 1. 2. 3. clear accerr/pviol 0x30 write: fstat register yes no access error and protection violation and dummy data read: fstat register read: fstat register no start yes check cbeif set? address, data, command buffer empty check accerr/ pviol set? exit write: fclkdiv register read: fclkdiv register yes no clock register written check fdivld set? note: fclkdiv needs to be set once after each reset. no bit polling for command completion check yes ccif set?
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 595 rev 1.09 20.4.1.4 illegal flash operations 20.4.1.4.1 access error the accerr ?g in the fstat register will be set during the command write sequence if any of the following illegal flash operations are performed causing the command write sequence to immediately abort: 1. writing to the flash address space before initializing the fclkdiv register 2. writing a misaligned word or a byte to the valid flash address space 3. writing to the flash address space while cbeif is not set 4. writing a second word to the flash address space before executing a program or erase command on the previously written word 5. writing to any flash register other than fcmd after writing a word to the flash address space 6. writing a second command to the fcmd register before executing the previously written command 7. writing an invalid command to the fcmd register 8. writing to any flash register other than fstat (to clear cbeif) after writing to the fcmd register 9. the part enters stop mode and a program or erase command is in progress. the command is aborted and any pending command is killed 10. when security is enabled, a command other than mass erase originating from a non-secure memory or from the background debug mode is written to the fcmd register 11. a 0 is written to the cbeif bit in the fstat register to abort a command write sequence. the accerr ?g will not be set if any flash register is read during the command write sequence. if the flash array is read during execution of an algorithm (ccif=0), the flash module will return invalid data and the accerr ?g will not be set. if an accerr ?g is set in the fstat register, the flash command controller is locked. it is not possible to launch another command until the accerr ?g is cleared. 20.4.1.4.2 protection violation the pviol ?g in the fstat register will be set during the command write sequence after the word write to the flash address space if any of the following illegal flash operations are performed, causing the command write sequence to immediately abort: 1. writing a flash address to program in a protected area of the flash array (see section 20.3.2.5 ). 2. writing a flash address to erase in a protected area of the flash array. 3. writing the mass erase command to the fcmd register while any protection is enabled. if the pviol ?g is set, the flash command controller is locked. it is not possible to launch another command until the pviol ?g is cleared.
chapter 20 128 kbyte flash module (s12fts128k1v1) 596 mc9s12q128 freescale semiconductor rev 1.09 20.4.2 operating modes 20.4.2.1 wait mode if the mcu enters wait mode while a flash command is active (ccif = 0), that command and any buffered command will be completed. the flash module can recover the mcu from wait mode if the interrupts are enabled (see section 20.4.5 ). 20.4.2.2 stop mode if the mcu enters stop mode while a flash command is active (ccif = 0), that command will be aborted and the data being programmed or erased is lost. the high voltage circuitry to the flash array will be switched off when entering stop mode. ccif and accerr ?gs will be set. upon exit from stop mode, the cbeif ?g will be set and any buffered command will not be executed. the accerr ?g must be cleared before returning to normal operation. note as active flash commands are immediately aborted when the mcu enters stop mode, it is strongly recommended that the user does not use the stop instruction during program and erase execution. 20.4.2.3 background debug mode in background debug mode (bdm), the fprot register is writable. if the mcu is unsecured, then all flash commands listed in table 20-16 can be executed. if the mcu is secured and is in special single chip mode, the only possible command to execute is mass erase. 20.4.3 flash module security the flash module provides the necessary security information to the mcu. after each reset, the flash module determines the security state of the mcu as de?ed in section 20.3.2.2, ?lash security register (fsec) . the contents of the flash security/options byte at address 0xff0f in the flash con?uration ?ld must be changed directly by programming address 0xff0f when the device is unsecured and the higher address sector is unprotected. if the flash security/options byte is left in the secure state, any reset will cause the mcu to return to the secure operating mode. 20.4.3.1 unsecuring the mcu using backdoor key access the mcu may only be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor key (four 16-bit words programmed at addresses 0xff00?xff07). if keyen[1:0] = 1:0 and the keyacc bit is set, a write to a backdoor key address in the flash array triggers a comparison between the written data and the backdoor key data stored in the flash array. if all four words of data are written to the correct addresses in the correct order and the data matches the backdoor key stored in the flash array, the mcu will be unsecured. the data must be written to the backdoor key
chapter 20 128 kbyte flash module (s12fts128k1v1) freescale semiconductor mc9s12q128 597 rev 1.09 addresses sequentially staring with 0xff00-0xff01 and ending with 0xff06?xff07. the values 0x0000 and 0xffff are not permitted as keys. when the keyacc bit is set, reads of the flash array will return invalid data. the user code stored in the flash array must have a method of receiving the backdoor key from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if keyen[1:0] = 1:0 in the fsec register, the mcu can be unsecured by the backdoor key access sequence described below: 1. set the keyacc bit in the fcnfg register 2. write the correct four 16-bit words to flash addresses 0xff00?xff07 sequentially starting with 0xff00 3. clear the keyacc bit in the fcnfg register 4. if all four 16-bit words match the backdoor key stored in flash addresses 0xff00?xff07, the mcu is unsecured and bits sec[1:0] in the fsec register are forced to the unsecure state of 1:0 the backdoor key access sequence is monitored by the internal security state machine. an illegal operation during the backdoor key access sequence will cause the security state machine to lock, leaving the mcu in the secured state. a reset of the mcu will cause the security state machine to exit the lock state and allow a new backdoor key access sequence to be attempted. the following illegal operations will lock the security state machine: 1. if any of the four 16-bit words does not match the backdoor key programmed in the flash array 2. if the four 16-bit words are written in the wrong sequence 3. if more than four 16-bit words are written 4. if any of the four 16-bit words written are 0x0000 or 0xffff 5. if the keyacc bit does not remain set while the four 16-bit words are written after the backdoor key access sequence has been correctly matched, the mcu will be unsecured. the flash security byte can be programmed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the four word backdoor key by programming bytes 0xff00?xff07 of the flash con?uration ?ld. the security as de?ed in the flash security/options byte at address 0xff0f is not changed by using the backdoor key access sequence to unsecure. the backdoor key stored in addresses 0xff00?xff07 is unaffected by the backdoor key access sequence. after the next reset sequence, the security state of the flash module is determined by the flash security/options byte at address 0xff0f. the backdoor key access sequence has no effect on the program and erase protection de?ed in the fprot register. it is not possible to unsecure the mcu in special single chip mode by executing the backdoor key access sequence in background debug mode.
chapter 20 128 kbyte flash module (s12fts128k1v1) 598 mc9s12q128 freescale semiconductor rev 1.09 20.4.4 flash reset sequence on each reset, the flash module executes a reset sequence to hold cpu activity while loading the following registers from the flash array memory according to table 20-1 : fprot ?flash protection register (see section 20.3.2.5 ) fsec ?flash security register (see section 20.3.2.2 ) 20.4.4.1 reset while flash command active if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/array being erased is not guaranteed. 20.4.5 interrupts the flash module can generate an interrupt when all flash commands have completed execution or the flash address, data, and command buffers are empty. note vector addresses and their relative interrupt priority are determined at the mcu level. 20.4.5.1 description of interrupt operation figure 20-26 shows the logic used for generating interrupts. the flash module uses the cbeif and ccif ?gs in combination with the enable bits cbie and ccie to discriminate for the generation of interrupts. figure 20-26. flash interrupt implementation for a detailed description of these register bits, refer to section 20.3.2.4, ?lash con?uration register (fcnfg) and section 20.3.2.6, ?lash status register (fstat) . table 20-17. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash address, data, and command buffers are empty cbeif (fstat register) cbeie i bit all flash commands have completed execution ccif (fstat register) ccie i bit cbeif cbeie ccif ccie flash interrupt request
appendix a electrical characteristics freescale semiconductor mc9s12q128 599 rev 1.09 appendix a electrical characteristics a.1 general note the electrical characteristics given in this section are preliminary and should be used as a guide only. values cannot be guaranteed by freescale and are subject to change without notice. the parts are speci?d and tested over the 5v and 3.3v ranges. for the intermediate range, generally the electrical speci?ations for the 3.3v range apply, but the parts are not tested in production test in the intermediate range. this supplement contains the most accurate electrical information for the mc9s12q128 microcontrollers available at the time of publication. the information should be considered preliminary and is subject to change. this introduction is intended to give an overview on several common topics like power supply, current injection etc. a.1.1 parameter classi?ation the electrical parameters shown in this supplement are guaranteed by various methods. to give the customer a better understanding the following classi?ation is used and the parameters are tagged accordingly in the tables where appropriate. note this classi?ation will be added at a later release of the speci?ation p: those parameters are guaranteed during production testing on each individual device. c: those parameters are achieved by the design characterization by measuring a statistically relevant sample size across process variations. they are regularly veri?d by production monitors. t: those parameters are achieved by design characterization on a small sample size from typical devices. all values shown in the typical column are within this category. d: those parameters are derived mainly from simulations. a.1.2 power supply the mc9s12q128 members utilize several pins to supply power to the i/o ports, a/d converter, oscillator and pll as well as the internal logic. the v dda , v ssa pair supplies the a/d converter. the v ddx , v ssx pair supplies the i/o pins the v ddr , v ssr pair supplies the internal voltage regulator.
appendix a electrical characteristics 600 mc9s12q128 freescale semiconductor rev 1.09 v dd1 , v ss1 , v dd2 and v ss2 are the supply pins for the digital logic. v ddpll , v sspll supply the oscillator and the pll. v ss1 and v ss2 are internally connected by metal. v dd1 and v dd2 are internally connected by metal. v dda , v ddx , v ddr as well as v ssa , v ssx, v ssr are connected by anti-parallel diodes for esd protection. note in the following context vdd5 is used for either v dda ,v ddr , and v ddx ; v ss5 is used for either v ssa , v ssr , and v ssx unless otherwise noted. idd5 denotes the sum of the currents ?wing into the v dda , v ddx , and v ddr pins. v dd is used for v dd1 ,v dd2 , and v ddpll ,v ss is used for v ss1 ,v ss2 , and v sspll . i dd is used for the sum of the currents ?wing into v dd1 and v dd2 . a.1.3 pins there are four groups of functional pins. a.1.3.1 5v i/o pins those i/o pins have a nominal level of 5v. this class of pins is comprised of all port i/o pins, the analog inputs, bkgd pin, and the reset inputs.the internal structure of all those pins is identical; however some of the functionality may be disabled. for example, pull-up and pull-down resistors may be disabled permanently. a.1.3.2 analog reference this class is made up by the two v rh and v rl pins. in 48- and 52-pin package versions the v rl pad is bonded to the v ssa pin. a.1.3.3 oscillator the pins xfc, extal, xtal dedicated to the oscillator have a nominal 2.5v level. they are supplied by v ddpll . a.1.3.4 test this pin is used for production testing only. a.1.4 current injection power supply must maintain regulation within operating v dd5 or v dd range during instantaneous and operating maximum current conditions. if positive injection current (v in >v dd5 ) is greater than i dd5 , the
appendix a electrical characteristics freescale semiconductor mc9s12q128 601 rev 1.09 injection current may ?w out of v dd5 and could result in external power supply going out of regulation. insure external v dd5 load will shunt current greater than maximum injection current. this will be the greatest risk when the mcu is not consuming power; e.g. if no system clock is present, or if clock rate is very low which would reduce overall power consumption. a.1.5 absolute maximum ratings absolute maximum ratings are stress ratings only. a functional operation under or outside those maxima is not guaranteed. stress beyond those limits may affect the reliability or cause permanent damage of the device. this device contains circuitry protecting against damage due to high static voltage or electrical ?lds; however, it is advised that normal precautions be taken to avoid application of any voltages higher than maximum-rated voltages to this high-impedance circuit. reliability of operation is enhanced if unused inputs are tied to an appropriate logic voltage level (e.g., either v ss5 or v dd5 ). table a-1. absolute maximum ratings num rating symbol min max unit 1 i/o, regulator and analog supply voltage v dd5 ?.3 6.5 v 2 digital logic supply voltage (1) 1. the device contains an internal voltage regulator to generate the logic and pll supply out of the i/o supply. the absolute maximum ratings apply when the device is powered from an external source. v dd ?.3 3.0 v 3 pll supply voltage 1 v ddpll ?.3 3.0 v 4 voltage difference v ddx to v ddr and v dda ? vddx ?.3 0.3 v 5 voltage difference v ssx to v ssr and v ssa ? vssx ?.3 0.3 v 6 digital i/o input voltage v in ?.3 6.5 v 7 analog reference v rh, v rl ?.3 6.5 v 8 xfc, extal, xtal inputs v ilv ?.3 3.0 v 9 test input v test ?.3 10.0 v 10 instantaneous maximum current single pin limit for all digital i/o pins (2) 2. all digital i/o pins are internally clamped to v ssx and v ddx , v ssr and v ddr or v ssa and v dda . i d ?5 +25 ma 11 instantaneous maximum current single pin limit for xfc, extal, xtal (3) 3. these pins are internally clamped to v sspll and v ddpll i dl ?5 +25 ma 12 instantaneous maximum current single pin limit for test (4) 4. this pin is clamped low to v ssx , but not clamped high. this pin must be tied low in applications. i dt ?.25 0 ma 13 operating temperature range (packaged) t a ?40 125 c 14 operating temperature range (junction) t j ?40 140 c 15 storage temperature range t stg ?65 155 c
appendix a electrical characteristics 602 mc9s12q128 freescale semiconductor rev 1.09 a.1.6 esd protection and latch-up immunity all esd testing is in conformity with cdf-aec-q100 stress test quali?ation for automotive grade integrated circuits. during the device quali?ation esd stresses were performed for the human body model (hbm), the machine model (mm) and the charge device model. a device will be de?ed as a failure if after exposure to esd pulses the device no longer meets the device speci?ation. complete dc parametric and functional testing is performed per the applicable device speci?ation at room temperature followed by hot temperature, unless speci?d otherwise in the device speci?ation. table a-2. esd and latch-up test conditions model description symbol value unit human body series resistance r1 1500 ohm storage capacitance c 100 pf number of pulse per pin positive negative 3 3 machine series resistance r1 0 ohm storage capacitance c 200 pf number of pulse per pin positive negative 3 3 latch-up minimum input voltage limit ?.5 v maximum input voltage limit 7.5 v table a-3. esd and latch-up protection characteristics num c rating symbol min max unit 1 c human body model (hbm) v hbm 2000 v 2 c machine model (mm) v mm 200 v 3 c charge device model (cdm) v cdm 500 v 4c latch-up current at 125 c positive negative i lat +100 ?00 ma 5c latch-up current at 27 c positive negative i lat +200 ?00 ma
appendix a electrical characteristics freescale semiconductor mc9s12q128 603 rev 1.09 a.1.7 operating conditions this chapter describes the operating conditions of the devices. unless otherwise noted those conditions apply to all the following data. note instead of specifying ambient temperature all parameters are speci?d for the more meaningful silicon junction temperature. for power dissipation calculations refer to section a.1.8, ?ower dissipation and thermal characteristics . table a-4. operating conditions rating symbol min typ max unit i/o, regulator and analog supply voltage v dd5 2.97 5 5.5 v digital logic supply voltage (1) 1. the device contains an internal voltage regulator to generate the logic and pll supply out of the i/o supply. the operating conditions apply when this regulator is disabled and the device is powered from an external source. using an external regulator, with the internal voltage regulator disabled, an external lvr must be provided. v dd 2.35 2.5 2.75 v pll supply voltage 1 v ddpll 2.35 2.5 2.75 v voltage difference v ddx to v dda ? vddx ?.1 0 0.1 v voltage difference v ssx to v ssr and v ssa ? vssx ?.1 0 0.1 v bus frequency f bus (2) 2. some blocks e.g. atd (conversion) and nvms (program/erase) require higher bus frequencies for proper operation. 0.25 16 mhz operating junction temperature range t j ?0 140 c
appendix a electrical characteristics 604 mc9s12q128 freescale semiconductor rev 1.09 a.1.8 power dissipation and thermal characteristics power dissipation and thermal characteristics are closely related. the user must assure that the maximum operating junction temperature is not exceeded. the average chip-junction temperature (t j ) in c can be obtained from: the total power dissipation can be calculated from: two cases with internal voltage regulator enabled and disabled must be considered: 1. internal voltage regulator disabled which is the sum of all output currents on i/o ports associated with v ddx and v ddm . for r dson is valid: respectively 2. internal voltage regulator enabled i ddr is the current shown in table a-8 and not the overall current ?wing into vddr, which additionally contains the current ?wing into the external loads with output high. which is the sum of all output currents on i/o ports associated with v ddx and v ddr . t j t a p d ja ? () + = t j junction temperature, [ c ] = t a ambient temperature, [ c ] = p d total chip power dissipation, [w] = ja package thermal resistance, [ c/w] = p d p int p io + = p int chip internal power dissipation, [w] = p int i dd v dd ? i ddpll v ddpll ? i dda +v dda ? + = p io r dson i i io i 2 ? = r dson v ol i ol ------------ for outputs driven low ; = r dson v dd5 v oh i oh ------------------------------------ for outputs driven high ; = p int i ddr v ddr ? i dda v dda ? + = p io r dson i i io i 2 ? =
appendix a electrical characteristics freescale semiconductor mc9s12q128 605 rev 1.09 table a-5. thermal package characteristics (1) 1. the values for thermal resistance are achieved by package simulations num c rating symbol min typ max unit 1 t thermal resistance lqfp48, single layer pcb (2) 2. pc board according to eia/jedec standard 51-2 ja 69 o c/w 2t thermal resistance lqfp48, double sided pcb with 2 internal planes (3) 3. pc board according to eia/jedec standard 51-7 ja 53 o c/w 3 t junction to board lqfp48 jb 30 o c/w 4 t junction to case lqfp48 jc 20 o c/w 5 t junction to package top lqfp48 jt 4 o c/w 6 t thermal resistance lqfp52, single sided pcb ja 65 o c/w 7t thermal resistance lqfp52, double sided pcb with 2 internal planes ja 49 o c/w 8 t junction to board lqfp52 jb 31 o c/w 9 t junction to case lqfp52 jc 17 o c/w 10 t junction to package top lqfp52 jt 3 o c/w 11 t thermal resistance qfp 80, single sided pcb ja 52 o c/w 12 t thermal resistance qfp 80, double sided pcb with 2 internal planes ja 42 o c/w 13 t junction to board qfp80 jb 28 o c/w 14 t junction to case qfp80 jc 18 o c/w 15 t junction to package top qfp80 jt 4 o c/w
appendix a electrical characteristics 606 mc9s12q128 freescale semiconductor rev 1.09 a.1.9 i/o characteristics this section describes the characteristics of all i/o pins. all parameters are not always applicable, e.g. not all pins feature pull up/down resistances. table a-6. 5v i/o characteristics conditions are 4.5< v ddx <5.5v temperature from ?0?c to +140?c, unless otherwise noted num c rating symbol min typ max unit 1 p input high voltage v ih 0.65*v dd5 v t input high voltage v ih v dd5 + 0.3 v 2 p input low voltage v il 0.35*v dd5 v t input low voltage v il v ss5 - 0.3 v 3 c input hysteresis v hys 250 mv 4p input leakage current (pins in high ohmic input mode) (1) v in = v dd5 or v ss5 1. maximum leakage current occurs at maximum operating temperature. current decreases by approximately one-half for each 8 c to 12 c in the temper ature range from 50 c to 125 c . i in 1 a 5c output high voltage (pins in output mode) partial drive i oh = ?ma v oh v dd5 ?0.8 v 6p output high voltage (pins in output mode) full drive i oh = ?0ma v oh v dd5 ?0.8 v 7c output low voltage (pins in output mode) partial drive i ol = +2ma v ol 0.8 v 8p output low voltage (pins in output mode) full drive i ol = +10ma v ol 0.8 v 9p internal pull up device current, tested at v il max. i pul ?30 a 10 c internal pull up device current, tested at v ih min. i puh ?0 a 11 p internal pull down device current, tested at v ih min. i pdh 130 a 12 c internal pull down device current, tested at v il max. i pdl 10 a 13 d input capacitance c in ? pf 14 t injection current (2) single pin limit total device limit. sum of all injected currents 2. refer to section a.1.4, ?urrent injection , for more details i ics i icp ?.5 ?5 2.5 25 m 15 p port p, j interrupt input pulse ?tered (3) 3. parameter only applies in stop or pseudo stop mode. t pign 3 s 16 p port p, j interrupt input pulse passed 3 t pval 10 s
appendix a electrical characteristics freescale semiconductor mc9s12q128 607 rev 1.09 a.1.10 supply currents this section describes the current consumption characteristics of the device as well as the conditions for the measurements. a.1.10.1 measurement conditions all measurements are without output loads. unless otherwise noted the currents are measured in single chip mode, internal voltage regulator enabled and at 16mhz bus frequency using a 4mhz oscillator. table a-7. 3.3v i/o characteristics conditions are v ddx =3.3v +/-10%, temperature from ?0?c to +140?c, unless otherwise noted num c rating symbol min typ max unit 1 p input high voltage v ih 0.65*v dd5 v t input high voltage v ih v dd5 + 0.3 v 2 p input low voltage v il 0.35*v dd5 v t input low voltage v il v ss5 ?0.3 v 3 c input hysteresis v hys 250 mv 4p input leakage current (pins in high ohmic input mode) (1) v in = v dd5 or v ss5 1. maximum leakage current occurs at maximum operating temperature. current decreases by approximately one-half for each 8 c to 12 c in the temper ature range from 50 c to 125 c . i in ? 1 a 5c output high voltage (pins in output mode) partial drive i oh = ?.75ma v oh v dd5 ?0.4 v 6p output high voltage (pins in output mode) full drive i oh = ?ma v oh v dd5 ?0.4 v 7c output low voltage (pins in output mode) partial drive i ol = +0.9ma v ol 0.4 v 8p output low voltage (pins in output mode) full drive i ol = +4.75ma v ol 0.4 v 9 p internal pull up device current, tested at v il max. i pul ?0 a 10 c internal pull up device current, tested at v ih min. i puh -6 a 11 p internal pull down device current, tested at v ih min. i pdh 60 a 12 c internal pull down device current, tested at v il max. i pdl 6 a 11 d input capacitance c in ? 12 t injection current (2) single pin limit total device limit. sum of all injected currents 2. refer to section a.1.4, ?urrent injection , for more details i ics i icp ?.5 ?5 2.5 25 ? 13 p port p, j interrupt input pulse ?tered (3) 3. parameter only applies in stop or pseudo stop mode. t pign 3 s 14 p port p, j interrupt input pulse passed 3 t pval 10 s
appendix a electrical characteristics 608 mc9s12q128 freescale semiconductor rev 1.09 a.1.10.2 additional remarks in expanded modes the currents ?wing in the system are highly dependent on the load at the address, data and control signals as well as on the duty cycle of those signals. no generally applicable numbers can be given. a very good estimate is to take the single chip currents and add the currents due to the external loads. table a-8. supply current characteristics for mc9s12q32 conditions are shown in table a-4 with internal regulator enabled unless otherwise noted num c rating symbol min typ max unit 1 p run supply current single chip i dd5 35 ma 2 p p c wait supply current all modules enabled v ddr <4.9v, only rti enabled 2 v ddr >4.9v, only rti enabled i ddw 3.5 2.5 30 8 ma 3 c p c p c p c p pseudo stop current (rti and cop disabled) 23 ?0 c 27 c 85 c "c" temp option 100?c 105 c "v" temp option 120?c 125 c "m" temp option 140 c i ddps (1) 1. stop current measured in production test at increased junction temperature, hence for temp option "c" the test is carried out at 100?c although the temperature speci?ation is 85?c. similarly for "v" and "m" options the temperature used in test lies 15?c above the temperature option speci?ation. 340 360 500 550 590 720 780 1100 450 1450 1900 4500 a 4 c c c c c pseudo stop current (rti and cop enabled) (2) (3) ?0 c 27 c 85 c 105 c 125 c 2. pll off 3. at those low power dissipation levels t j = t a can be assumed i ddps 1 540 700 750 880 1300 a 5 c p c p c p c p stop current 3 ?0 c 27 c 85 c "c" temp option 100?c 105 c "v" temp option 120?c 125 c "m" temp option 140 c i dds 1 10 20 100 140 170 300 350 520 80 1000 1400 4000 a
appendix a electrical characteristics freescale semiconductor mc9s12q128 609 rev 1.09 table a-9. supply current characteristics for other family members conditions are shown in table a-4 with internal regulator enabled unless otherwise noted num c rating symbol min typ max unit 1 p run supply current single chip, i dd5 45 ma 2 p p c wait supply current all modules enabled vddr<4.9v, only rti enabled 2 vddr>4.9v, only rti enabled i ddw 2.5 3.5 33 8 ma 6 c p c p c p c p pseudo stop current (rti and cop disabled) 23 ?0 c 27 c 85 c "c" temp option 100?c 105 c "v" temp option 120?c 125 c "m" temp option 140 c i ddps (1) 1. stop current measured in production test at increased junction temperature, hence for temp option "c" the test is carried out at 100?c although the temperature speci?ation is 85?c. similarly for "v" and "m" options the temperature used in test lies 15?c above the temperature option speci?ation. 190 200 300 400 450 600 650 1000 250 1400 1900 4800 a 4 c c c c c pseudo stop current (rti and cop enabled) (2) (3) ?0 c 27 c 85 c 105 c 125 c 2. pll off 3. at those low power dissipation levels t j = t a can be assumed i ddps 1 370 500 590 780 1200 a 5 c p c p c p c p stop current 3 ?0 c 27 c 85 c "c" temp option 100?c 105 c "v" temp option 120?c 125 c "m" temp option 140 c i dds 1 12 25 130 160 200 350 400 600 100 1200 1700 4500 a
appendix a electrical characteristics 610 mc9s12q128 freescale semiconductor rev 1.09 a.2 atd characteristics this section describes the characteristics of the analog-to-digital converter. v rl is not available as a separate pin in the 48- and 52-pin versions. in this case the internal v rl pad is bonded to the v ssa pin. the atd is speci?d and tested for both the 3.3v and 5v range. for ranges between 3.3v and 5v the atd accuracy is generally the same as in the 3.3v range but is not tested in this range in production test. a.2.1 atd operating characteristics in 5v range the table a-10 shows conditions under which the atd operates. the following constraints exist to obtain full-scale, full range results: v ssa v rl v in v rh v dda . this constraint exists since the sample buffer ampli?r can not drive beyond the power supply levels that it ties to. if the input level goes outside of this range it will effectively be clipped. table a-10. atd operating characteristics conditions are shown in table a-4 unless otherwise noted. supply voltage 5v-10% <= v dda <=5v+10% num c rating symbol min typ max unit 1d reference potential low high v rl v rh v ssa v dda/2 v dda/2 v dda v v 2 c differential reference voltage (1) 1. full accuracy is not guaranteed when differential voltage is less than 4.75v v rh -v rl 4.75 5.0 5.25 v 3 d atd clock frequency f atdclk 0.5 2.0 mhz 4d atd 10-bit conversion period clock cycles (2) conv, time at 2.0mhz atd clock f atdclk 2. the minimum time assumes a ?al sample period of 2 atd clocks cycles while the maximum time assumes a ?al sample period of 16 atd clocks. n conv10 t conv10 14 7 28 14 cycles s 5d atd 8-bit conversion period clock cycles 2 conv, time at 2.0mhz atd clock f atdclk n conv10 t conv10 12 6 26 13 cycles s 5 d recovery time (v dda =5.0 volts) t rec 20 s 6 p reference supply current i ref 0.375 ma
appendix a electrical characteristics freescale semiconductor mc9s12q128 611 rev 1.09 a.2.2 atd operating characteristics in 3.3v range the table a-11 shows conditions under which the atd operates. the following constraints exist to obtain full-scale, full range results: v ssa v rl v in v rh v dda . this constraint exists since the sample buffer ampli?r can not drive beyond the power supply levels that it ties to. if the input level goes outside of this range it will effectively be clipped a.2.3 factors in?encing accuracy three factors ?source resistance, source capacitance and current injection ?have an in?ence on the accuracy of the atd. a.2.3.1 source resistance due to the input pin leakage current as speci?d in table a-6 in conjunction with the source resistance there will be a voltage drop from the signal source to the atd input. the maximum source resistance r s speci?s results in an error of less than 1/2 lsb (2.5mv) at the maximum leakage current. if device or operating conditions are less than worst case or leakage-induced error is acceptable, larger values of source resistance is allowable. a.2.3.2 source capacitance when sampling an additional internal capacitor is switched to the input. this can cause a voltage drop due to charge sharing with the external and the pin capacitance. for a maximum sampling error of the input voltage 1lsb, then the external ?ter capacitor, c f 1024 * (c ins ?c inn ). table a-11. atd operating characteristics conditions are shown in table a-4 unless otherwise noted; supply voltage 3.3v-10% <= v dda <= 3.3v+10% num c rating symbol min typ max unit 1d reference potential low high v rl v rh v ssa v dda /2 v dda /2 v dda v v 2 c differential reference voltage v rh -v rl 3.0 3.3 3.6 v 3 d atd clock frequency f atdclk 0.5 2.0 mhz 4d atd 10-bit conversion period clock cycles (1) conv, time at 2.0mhz atd clock f atdclk 1. the minimum time assumes a ?al sample period of 2 atd clocks cycles while the maximum time assumes a ?al sample period of 16 atd clocks. n conv10 t conv10 14 7 28 14 cycles s 5d atd 8-bit conversion period clock cycles 1 conv, time at 2.0mhz atd clock f atdclk n conv8 t conv8 12 6 26 13 cycles s 6 d recovery time (v dda =3.3 volts) t rec 20 s 7 p reference supply current i ref 0.250 ma
appendix a electrical characteristics 612 mc9s12q128 freescale semiconductor rev 1.09 a.2.3.3 current injection there are two cases to consider. 1. a current is injected into the channel being converted. the channel being stressed has conversion values of $3ff ($ff in 8-bit mode) for analog inputs greater than v rh and $000 for values less than v rl unless the current is higher than speci?d as disruptive conditions. 2. current is injected into pins in the neighborhood of the channel being converted. a portion of this current is picked up by the channel (coupling ratio k), this additional current impacts the accuracy of the conversion depending on the source resistance. the additional input voltage error on the converted channel can be calculated as v err =k*r s * i inj , with i inj being the sum of the currents injected into the two pins adjacent to the converted channel. a.2.4 atd accuracy (5v range) table a-12 speci?s the atd conversion performance excluding any errors due to current injection, input capacitance and source resistance . table 20-18. atd electrical characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1c max input source resistance r s 1k ? 2t total input capacitance non sampling sampling c inn c ins 10 15 pf 3c disruptive analog input current i na ?.5 2.5 ma 4c coupling ratio positive current injection k p 10 -4 a/a 5c coupling ratio negative current injection k n 10 -2 a/a table a-12. atd conversion performance conditions are shown in table a-4 unless otherwise noted v ref = v rh ?v rl = 5.12v. resulting to one 8 bit count = 20mv and one 10 bit count = 5mv f atdclk = 2.0mhz num c rating symbol min typ max unit 1 p 10-bit resolution lsb 5 mv 2 p 10-bit differential nonlinearity dnl ? 1 counts 3 p 10-bit integral nonlinearity inl ? 2 counts 4 p 10-bit absolute error (1) 1. these values include quantization error which is inherently 1/2 count for any a/d converter. ae -2.5 2.5 counts 5 p 8-bit resolution lsb 20 mv 6 p 8-bit differential nonlinearity dnl ?.5 0.5 counts 7 p 8-bit integral nonlinearity inl ?.0 0.5 1.0 counts 8 p 8-bit absolute error 1 ae -1.5 1 1.5 counts
appendix a electrical characteristics freescale semiconductor mc9s12q128 613 rev 1.09 a.2.5 atd accuracy (3.3v range) table a-13 speci?s the atd conversion performance excluding any errors due to current injection, input capacitance and source resistance. for the following de?itions see also figure a-1 . differential non-linearity (dnl) is de?ed as the difference between two adjacent switching steps. the integral non-linearity (inl) is de?ed as the sum of all dnls: table a-13. atd conversion performance conditions are shown in table a-4 unless otherwise noted v ref = v rh - v rl = 3.328v. resulting to one 8 bit count = 13mv and one 10 bit count = 3.25mv f atdclk = 2.0mhz num c rating symbol min typ max unit 1 p 10-bit resolution lsb 3.25 mv 2 p 10-bit differential nonlinearity dnl ?.5 1.5 counts 3 p 10-bit integral nonlinearity inl ?.5 1.5 3.5 counts 4 p 10-bit absolute error (1) 1. these values include the quantization error which is inherently 1/2 count for any a/d converter. ae ? 2.5 5 counts 5 p 8-bit resolution lsb 13 mv 6 p 8-bit differential nonlinearity dnl ?.5 0.5 counts 7 p 8-bit integral nonlinearity inl ?.5 1 1.5 counts 8 p 8-bit absolute error 1 ae ?.0 1.5 2.0 counts dnl i () v i v i1 1lsb -------------------------- - 1 = inl n () dnl i () i1 = n v n v 0 1lsb -------------------- - n ==
appendix a electrical characteristics 614 mc9s12q128 freescale semiconductor rev 1.09 figure a-1. atd accuracy de?itions note figure a-1 shows only de?itions, for speci?ation values refer to table a- 12 . 1 3.25 vin mv 6.5 9.75 13 16.25 19.5 22.75 26 3305 3309 3312 3315 3318 3321 3324 3328 3292 3295 3299 3302 3289 0 3 2 5 4 7 6 29.25 $3f7 $3f9 $3f8 $3fb $3fa $3fd $3fc $3fe $3ff $3f4 $3f6 $3f5 8 9 1 2 $ff $fe $fd $3f3 10-bit resolution 8-bit resolution ideal transfer curve 10-bit transfer curve 8-bit transfer curve 3286 10-bit absolute error boundary 8-bit absolute error boundary lsb vi-1 vi dnl
appendix a electrical characteristics freescale semiconductor mc9s12q128 615 rev 1.09 a.3 mscan a.4 reset, oscillator and pll this section summarizes the electrical characteristics of the various startup scenarios for oscillator and phase-locked-loop (pll). a.4.1 startup table a-15 summarizes several startup characteristics explained in this section. detailed description of the startup behavior can be found in the clock and reset generator (crg) block user guide. a.4.1.1 por the release level v porr and the assert level v pora are derived from the v dd supply. they are also valid if the device is powered externally. after releasing the por reset the oscillator and the clock quality check are started. if after a time t cqout no valid oscillation is detected, the mcu will start using the internal self clock. the fastest startup time possible is given by n uposc . a.4.1.2 lvr the release level v lvrr and the assert level v lvra are derived from the v dd supply. they are also valid if the device is powered externally. after releasing the lvr reset the oscillator and the clock quality check are started. if after a time t cqout no valid oscillation is detected, the mcu will start using the internal self clock. the fastest startup time possible is given by n uposc . table a-14. mscan wake-up pulse characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 p mscan wake-up dominant pulse ?tered t wup 2 us 2 p mscan wake-up dominant pulse pass t wup 5us table a-15. startup characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 t por release level v porr 2.07 v 2 t por assert level v pora 0.97 v 3 d reset input pulse width, minimum input time pw rstl 2t osc 4 d startup from reset n rst 192 196 n osc 5d interrupt pulse width, irq edge-sensitive mode pw irq 20 ns 6 d wait recovery startup time t wrs 14 t cyc
appendix a electrical characteristics 616 mc9s12q128 freescale semiconductor rev 1.09 a.4.1.3 sram data retention provided an appropriate external reset signal is applied to the mcu, preventing the cpu from executing code when v dd5 is out of speci?ation limits, the sram contents integrity is guaranteed if after the reset the porf bit in the crg flags register has not been set. a.4.1.4 external reset when external reset is asserted for a time greater than pw rstl the crg module generates an internal reset, and the cpu starts fetching the reset vector without doing a clock quality check, if there was an oscillation before reset. a.4.1.5 stop recovery out of stop the controller can be woken up by an external interrupt. a clock quality check as after por is performed before releasing the clocks to the system. a.4.1.6 pseudo stop and wait recovery the recovery from pseudo stop and wait are essentially the same since the oscillator was not stopped in both modes. in pseudo stop mode the voltage regulator is switched to reduced performance mode to reduce power consumption. the returning out of pseudo stop to full performance takes t vup . the controller can be woken up by internal or external interrupts.after t wrs in wait or t vup +t wrs in pseudo stop the cpu starts fetching the interrupt vector. a.4.2 oscillator the device features an internal colpitts and pierce oscillator. the selection of colpitts oscillator or pierce oscillator/external clock depends on the xclks signal which is sampled during reset. pierce oscillator/external clock mode allows the input of a square wave. before asserting the oscillator to the internal system clocks the quality of the oscillation is checked for each start from either power-on, stop or oscillator fail. t cqout speci?s the maximum time before switching to the internal self clock mode after por or stop if a proper oscillation is not detected. the quality check also determines the minimum oscillator start-up time t uposc . the device also features a clock monitor. a clock monitor failure is asserted if the frequency of the incoming clock signal is below the assert frequency f cmfa.
appendix a electrical characteristics freescale semiconductor mc9s12q128 617 rev 1.09 table a-16. oscillator characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1a c crystal oscillator range (colpitts) f osc 0.5 16 mhz 1b c crystal oscillator range (pierce) (1) 4 1. depending on the crystal a damping series resistor might be necessary f osc 0.5 40 mhz 2 p startup current i osc 100 a 3 c oscillator start-up time (colpitts) t uposc ? (2) 2. f osc = 4mhz, c = 22pf. 100 (3) 3. maximum value is for extreme cases using high q, low frequency crystals ms 4 d clock quality check time-out t cqout 0.45 2.5 s 5 p clock monitor failure assert frequency f cmfa 50 100 200 khz 6 p external square wave input frequency (4) 4. only valid if pierce oscillator/external clock selected ( xclks = 0 during reset) f ext 0.5 50 mhz 7 d external square wave pulse width low t extl 9.5 ns 8 d external square wave pulse width high t exth 9.5 ns 9 d external square wave rise time t extr 1ns 10 d external square wave fall time t extf 1ns 11 d input capacitance (extal, xtal pins) c in ?pf 12 c dc operating bias in colpitts con?uration on extal pin v dcbias 1.1 v 13 p extal pin input high voltage 4 v ih,extal 0.75* v ddpll v t extal pin input high voltage 4 v ih,extal v ddpll +0.3 v 14 p extal pin input low voltage 4 v il,extal 0.25* v ddpll v t extal pin input low voltage 4 v il,extal v sspll -0.3 v 15 c extal pin input hysteresis 4 v hys,extal 250 mv
appendix a electrical characteristics 618 mc9s12q128 freescale semiconductor rev 1.09 a.4.3 phase locked loop the oscillator provides the reference clock for the pll. the plls voltage controlled oscillator (vco) is also the system clock source in self clock mode. a.4.3.1 xfc component selection this section describes the selection of the xfc components to achieve a good ?ter characteristics. figure a-2. basic pll functional diagram the following procedure can be used to calculate the resistance and capacitance values using typical values for k 1 , f 1 and i ch from table a-17 . the grey boxes show the calculation for f vco = 50mhz and f ref = 1mhz. e.g., these frequencies are used for f osc = 4mhz and a 16mhz bus clock. the vco gain at the desired vco frequency is approximated by: the phase detector relationship is given by: i ch is the current in tracking mode. f osc 1 refdv+1 f ref phase detector vco kv 1 synr+1 f vco loop divider kf 1 2 d f cmp cs r cp v ddpll xfc pin k v k 1 e f 1 f vco () k 1 1v ? ----------------------- ? = 100 e 60 50 () 100 --------------------- - ? = = -90.48mhz/v k i ch k v ? = = 316.7hz/ ?
appendix a electrical characteristics freescale semiconductor mc9s12q128 619 rev 1.09 the loop bandwidth f c should be chosen to ful?l the gardners stability criteria by at least a factor of 10, typical values are 50. = 0.9 ensures a good transient response. and ?ally the frequency relationship is de?ed as with the above values the resistance can be calculated. the example is shown for a loop bandwidth f c =10khz: the capacitance c s can now be calculated as: the capacitance c p should be chosen in the range of: a.4.3.2 jitter information the basic functionality of the pll is shown in figure a-3 . with each transition of the clock f cmp , the deviation from the reference clock f ref is measured and input voltage to the vco is adjusted accordingly. the adjustment is done continuously with no abrupt changes in the clock output frequency. noise, voltage, temperature and other factors cause slight variations in the control loop resulting in a clock jitter. this jitter affects the real minimum and maximum clock periods as illustrated in figure a-4 . f c 2 f ref ?? 1 2 + + ?? ?? ? ------------------------------------------ 1 10 ----- f c f ref 410 ? ------------ - 0.9 = () ; < ? < f c < 25khz n f vco f ref ------------- 2 s y n r 1 + () ? == = 50 r 2 nf c ??? k ---------------------------- - = =2* *50*10khz/(316.7hz/ ? ) =9.9k ? =~10k ? c s 2 2 ? f c r ?? --------------------- - 0.516 f c r ? -------------- - 0.9 = () ; = = 5.19nf =~ 4.7nf c s 20 ? c p c s 10 ? ? c p = 470pf
appendix a electrical characteristics 620 mc9s12q128 freescale semiconductor rev 1.09 figure a-3. jitter de?itions the relative deviation of t nom is at its maximum for one clock period, and decreases towards zero for larger number of clock periods (n). de?ing the jitter as: for n < 100, the following equation is a good ? for the maximum jitter: figure a-4. maximum bus clock jitter approximation this is very important to notice with respect to timers, serial modules where a pre-scaler will eliminate the effect of the jitter to a large extent. 2 3 n-1 n 1 0 t nom t max1 t min1 t maxn t minn jn () max 1 t max n () nt nom ? --------------------- 1 t min n () nt nom ? -------------------- - , ?? ?? ?? = jn () j 1 n -------- j 2 + = 1 5 10 20 n j(n)
appendix a electrical characteristics freescale semiconductor mc9s12q128 621 rev 1.09 a.5 nvm, flash, and eeprom a.5.1 nvm timing the time base for all nvm program or erase operations is derived from the oscillator. a minimum oscillator frequency f nvmosc is required for performing program or erase operations. the nvm modules do not have any means to monitor the frequency and will not prevent program or erase operation at frequencies above or below the speci?d minimum. attempting to program or erase the nvm modules at a lower frequency a full program or erase transition is not assured. the flash program and erase operations are timed using a clock derived from the oscillator using the fclkdiv and eclkdiv registers respectively. the frequency of this clock must be set within the limits speci?d as f nvmop . the minimum program and erase times shown in table a-18 are calculated for maximum f nvmop and maximum f bus . the maximum times are calculated for minimum f nvmop and a f bus of 2mhz. table a-17. pll characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 p self clock mode frequency f scm 1 5.5 mhz 2 d vco locking range f vco 8 50 mhz 3d lock detector transition from acquisition to tracking mode |? trk| 3?% (1) 1. % deviation from target frequency 4 d lock detection |? lock| 0 1.5 % 1 5 d un-lock detection |? unl| 0.5 2.5 % 1 6d lock detector transition from tracking to acquisition mode |? unt| 6?% 1 7 c pllon total stabilization delay (auto mode) (2) 2. f osc = 4mhz, f bus = 16mhz equivalent f vco = 50mhz: refdv = #$03, synr = #$018, cs = 4.7nf, cp = 470pf, rs = 10k ? . t stab 0.5 ms 8 d pllon acquisition mode stabilization delay 2 t acq 0.3 ms 9 d pllon tracking mode stabilization delay 2 t al 0.2 ms 10 d fitting parameter vco loop gain k 1 -100 mhz/v 11 d fitting parameter vco loop frequency f 1 60 mhz 12 d charge pump current acquisition mode | i ch | 38.5 a 13 d charge pump current tracking mode | i ch | 3.5 a 14 c jitter ? parameter 1 2 j 1 1.1 % 15 c jitter ? parameter 2 2 j 2 0.13 %
appendix a electrical characteristics 622 mc9s12q128 freescale semiconductor rev 1.09 a.5.1.1 single word programming the programming time for single word programming is dependant on the bus frequency as a well as on the frequency f nvmop and can be calculated according to the following formula. a.5.1.2 row programming generally the time to program a consecutive word can be calculated as: for theq16 and q32 device ?sh arrays, where up to 32 words in a row can be programmed consecutively by keeping the command pipeline ?led, the time to program a whole row is: for the q64,q96 and q128 device ?sh arrays, where up to 64 words in a row can be programmed consecutively by keeping the command pipeline ?led, the time to program a whole row is: row programming is more than 2 times faster than single word programming. a.5.1.3 sector erase erasing either a 512 byte or 1024 byte flash sector takes: the setup times can be ignored for this operation. a.5.1.4 mass erase erasing a nvm block takes: this is independent of sector size. the setup times can be ignored for this operation. t swpgm 9 1 f nvmop --------------------- ? 25 1 f bus ---------- ? + = t bwpgm 4 1 f nvmop --------------------- ? 9 1 f bus ---------- ? + = t brpgm t swpgm 31 t bwpgm ? + = t brpgm t swpgm 63 t bwpgm ? + = t era 4000 1 f nvmop --------------------- ? t mass 20000 1 f nvmop --------------------- ?
appendix a electrical characteristics freescale semiconductor mc9s12q128 623 rev 1.09 table a-18. nvm timing characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 d external oscillator clock f nvmosc 0.5 50 (1) 1. restrictions for oscillator in crystal mode apply! mhz 2 d bus frequency for programming or erase operations f nvmbus 1 mhz 3 d operating frequency f nvmop 150 200 khz 4 p single word programming time t swpgm 46 (2) 2. minimum programming times are achieved under maximum nvm operating frequency f nvmop and maximum bus frequency f bus . 74.5 (3) 3. maximum erase and programming times are achieved under particular combinations of f nvmop and bus frequency f bus. refer to formulae in sections a.3.1.1 - a.3.1.4 for guidance. s 5 d flash burst programming consecutive word t bwpgm 20.4 2 ?1 3 s 6 d flash burst programming time for 32 word row t brpgm 678.4 2 1035.5 3 s 6 d flash burst programming time for 64 word row t brpgm 1331.2 2 2027.5 3 s 7 p sector erase time t era 20 (4) 4. minimum erase times are achieved under maximum nvm operating frequency f nvmop . 26.7 3 ms 8 p mass erase time t mass 100 4 133 3 ms 9 d blank check time flash per block t check 11 (5) 5. minimum time, if ?st word in the array is not blank (512 byte sector size). 32778 (6) 6. maximum time to complete check on an erased block (512 byte sector size) (7) t cyc 7. where t cyc is the system bus clock period. 9 d blank check time flash per block t check 11 (8) 8. minimum time, if ?st word in the array is not blank (1024 byte sector size) 65546 (9) 9. maximum time to complete check on an erased block (1024 byte sector size). 7 t cyc
appendix a electrical characteristics 624 mc9s12q128 freescale semiconductor rev 1.09 a.5.2 nvm reliability the reliability of the nvm blocks is guaranteed by stress test during quali?ation, constant process monitors and burn-in to screen early life failures. the program/erase cycle count on the sector is incremented every time a sector or mass erase event is executed. table a-19. nvm reliability characteristics (1) 1. t javg will not exeed 85 c considering a typical temperature pro?e over the lifetime of a consumer, industrial or automotive application. conditions are shown in table a-4. unless otherwise noted num c rating symbol min typ max unit flash reliability characteristics 1 c data retention after 10,000 program/erase cycles at an average junction temperature of t javg 85 c t flret 15 100 (2) 2. typical data retention values are based on intrinsic capability of the technology measured at high temperature and de-rated to 25 c using the arrhenius equation. for additional information on how freescale de?es typical data retention, please refer to engineering bulletin eb618. years 2 c data retention with <100 program/erase cycles at an average junction temperature t javg 85 c 20 100 2 3 c number of program/erase cycles (?0 c t j 0 c) n fl 10,000 cycles 4 c number of program/erase cycles (0 c t j 140 c) 10,000 100,000 (3) 3. spec table quotes typical endurance evaluated at 25 c for this product family, typical endurance at various temperature can be estimated using the graph below. for additional information on how freescale de?es typical endurance, please refer to engineering bulletin eb619.
appendix a electrical characteristics freescale semiconductor mc9s12q128 625 rev 1.09 figure a-5. typical endurance vs temperature a.6 spi this section provides electrical parametrics and ratings for the spi. in table a-20 the measurement conditions are listed. a.6.1 master mode in figure a-6 the timing diagram for master mode with transmission format cpha=0 is depicted. table a-20. measurement conditions description value unit drive mode full drive mode load capacitance c load, on all outputs 50 pf thresholds for delay measurement points (20% / 80%) v ddx v typical endurance [10 3 cycles] operating temperature t j [ c] 0 50 100 150 200 250 300 350 400 450 500 -40 -20 0 20 40 60 80 100 120 140 ------ flash
appendix a electrical characteristics 626 mc9s12q128 freescale semiconductor rev 1.09 figure a-6. spi master timing (cpha=0) in figure a-7 the timing diagram for master mode with transmission format cpha=1 is depicted. figure a-7. spi master timing (cpha=1) sck (output) sck (output) miso (input) mosi (output) ss 1 (output) 1 9 5 6 msb in 2 bit 6 . . . 1 lsb in msb out 2 lsb out bit 6 . . . 1 11 4 4 2 10 (cpol = 0) (cpol = 1) 3 13 13 1. if con?ured as an output. 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb. 12 12 sck (output) sck (output) miso (input) mosi (output) 1 5 6 msb in 2 bit 6 . . . 1 lsb in master msb out 2 master lsb out bit 6 . . . 1 4 4 9 12 13 11 port data (cpol = 0) (cpol = 1) port data ss 1 (output) 2 12 13 3 1. if con?ured as output 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb.
appendix a electrical characteristics freescale semiconductor mc9s12q128 627 rev 1.09 in table a-21 the timing characteristics for master mode are listed. a.6.2 slave mode in figure a-8 the timing diagram for slave mode with transmission format cpha=0 is depicted. figure a-8. spi slave timing (cpha=0) table a-21. spi master mode timing characteristics num c characteristic symbol min typ max unit 1 p sck frequency f sck 1/2048 1 / 2f bus 1 p sck period t sck 2 2048 t bus 2 d enable lead time t lead 1/2 t sck 3 d enable lag time t lag 1/2 t sck 4 d clock (sck) high or low time t wsck 1/2 t sck 5 d data setup time (inputs) t su 8ns 6 d data hold time (inputs) t hi 8ns 9 d data valid after sck edge t vsck 30 ns 10 d data valid after ss fall (cpha=0) t vss 15 ns 11 d data hold time (outputs) t ho 20 ns 12 d rise and fall time inputs t r 8 ns 13 d rise and fall time outputs t rfo 8 ns sck (input) sck (input) mosi (input) miso (output) ss (input) 1 9 5 6 msb in bit 6 . . . 1 lsb in slave msb slave lsb out bit 6 . . . 1 11 4 4 2 7 (cpol = 0) (cpol = 1) 3 13 note: not defined! 12 12 11 see 13 note 8 10 see note
appendix a electrical characteristics 628 mc9s12q128 freescale semiconductor rev 1.09 in figure a-9 the timing diagram for slave mode with transmission format cpha=1 is depicted. figure a-9. spi slave timing (cpha=1) in table a-22 the timing characteristics for slave mode are listed. table a-22. spi slave mode timing characteristics num c characteristic symbol min typ max unit 1 d sck frequency f sck dc 1 / 4f bus 1 p sck period t sck 4 t bus 2 d enable lead time t lead 4t bus 3 d enable lag time t lag 4t bus 4 d clock (sck) high or low time t wsck 4t bus 5 d data setup time (inputs) t su 8ns 6 d data hold time (inputs) t hi 8ns 7 d slave access time (time to data active) t a 20 ns 8 d slave miso disable time t dis 22 ns 9d data valid after sck edge t vsck 30 + t bus (1) 1. t bus added due to internal synchronization delay ns 10 d data valid after ss fall t vss 30 + t bus 1 ns 11 d data hold time (outputs) t ho 20 ns 12 d rise and fall time inputs t r 8 ns 13 d rise and fall time outputs t rfo 8 ns sck (input) sck (input) mosi (input) miso (output) 1 5 6 msb in bit 6 . . . 1 lsb in msb out slave lsb out bit 6 . . . 1 4 4 9 12 13 11 (cpol = 0) (cpol = 1) ss (input) 2 12 13 3 note: not defined! slave 7 8 see note
appendix a electrical characteristics freescale semiconductor mc9s12q128 629 rev 1.09 a.7 voltage regulator a.7.1 voltage regulator operating conditions a.7.2 chip power-up and lvi/lvr graphical explanation voltage regulator sub modules lvi (low voltage interrupt), por (power-on reset) and lvr (low voltage reset) handle chip power-up or drops of the supply voltage. their function is described in figure a-10 . table a-23. voltage regulator electrical parameters num c characteristic symbol min typ max unit 1 p input voltages v vddr, a 2.97 5.5 v 3p output voltage core full performance mode v dd 2.35 2.5 2.75 v 4p low voltage interrupt (1) assert level (xl45j mask set) assert level (other mask sets) deassert level (xl45j mask set) deassert level (other mask sets) 1. monitors v dda , active only in full performance mode. indicates i/o & adc performance degradation due to low supply voltage. v lvia v lvia v lvid v lvid 4.30 4.00 4.42 4.15 4.53 4.37 4.65 4.52 4.77 4.66 4.89 4.77 v v v v 5p low voltage reset (2) , (3) assert level (xl45j mask set) assert level (other mask sets) 2. monitors v dd , active only in full performance mode. mcu is monitored by the por in rpm (see figure a-10 ) 3. digital functionality is guaranteed in the range between v dd (min) and v lvra (min). v lvra 2.25 2.25 2.3 2.35 v 7c power-on reset (4) assert level deassert level 4. monitors v dd . active in all modes. v pora v pord 0.97 2.05 v v
appendix a electrical characteristics 630 mc9s12q128 freescale semiconductor rev 1.09 figure a-10. voltage regulator ?chip power-up and voltage drops (not scaled) a.7.3 output loads a.7.3.1 resistive loads the on-chip voltage regulator is intended to supply the internal logic and oscillator circuits allows no external dc loads. a.7.3.2 capacitive loads the capacitive loads are speci?d in table a-24 . ceramic capacitors with x7r dielectricum are required. table a-24. voltage regulator ?capacitive loads num characteristic symbol min typical max unit 1v dd external capacitive load c ddext 400 440 12000 nf 2v ddpll external capacitive load c ddpllext 90 220 5000 nf v lvid v lvia v lvrd v lvra v pord lvi por lvr t v v dda v dd lvi enabled lvi disabled due to lvr
appendix b emulation information freescale semiconductor mc9s12q128 631 rev 1.09 appendix b emulation information b.1 general for emulation, external addressing of a 128k memory map is required. this is provided in a 112 lqfp package version of the mc9s12c128 which includes the 3 necessary extra external address bus signals via port k. this package version is for emulation only and not provided as a general production package. figure b-1. pin assignments in 112-pin lqfp vrh vdda nc pad07/an07 nc pad06/an06 nc pad05/an05 nc pad04/an04 nc pad03/an03 nc pad02/an02 nc pad01/an01 nc pad00/an00 vss2 vdd2 pa7/addr15/data15 pa6/addr14/data14 pa5/addr13/data13 pa4/addr12/data12 pa3/addr11/data11 pa2/addr10/data10 pa1/addr9/data9 pa0/addr8/data8 pp4/kwp4/pw4 pp5/kpw5/pwm nc pp7/kwp7/pw7 nc v ddx v ssx pm0/rxcan pm1/txcan pm2/mis pm3/ ss pm4/mosi pm5/sck pj6/kwj6 pj7/kwj7 nc nc pp6/kwp6/romone nc nc ps3 ps2 ps1/txd ps0/rxd nc nc vssa vrl pw3/kwp3/pp3 pw2/kwp2/pp2 pw1/kwp1/pp1 /pw0/kwp0/pp0 nc xaddr16/pk2 xaddr15/pk1 xaddr14/pk0 ioc0/pt0 ioc1/pt1 ioc2/pt2 ioc3/pt3 vdd1 vss1 ioc4/pt4 ioc5/pt5 ioc6/pt6 ioc7/pt7 nc nc nc nc modc/ t a ghi/bkgd addr0/data0/pb0 addr1/data1/pb1 addr2/data2/pb2 addr3/data3/pb3 addr4/data4/pb4 addr5/data5/pb5 addr6/data6/pb6 addr7/data7/pb7 nc nc nc nc xclks/noacc/pe7 modb/ipipe1/pe6 moda/ipipe0/pe5 eclk/pe4 vssr vddr reset vddpll xfc vsspll extal xtal test nc nc nc nc lstrb/ t a glo/pe3 r/ w/pe2 irq/pe1 xirq/pe0 signals shown in bold are available only in the 112 pin package. pins marked "nc" are not connected mc9s12c128 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57
appendix b emulation information 632 mc9s12q128 freescale semiconductor rev 1.09 b.1.1 pk[2:0] / xaddr[16:14] pk2-pk0 provide the expanded address xaddr[16:14] for the external bus. refer to the s12 core user guide for detailed information about external address page access. the reset state of ddrk in the s12_core is $00, con?uring the pins as inputs. the reset state of pupke in the pucr register of the s12_core is "1" enabling the internal pullup resistors at portk[2:0]. in this reset state the pull-up resistors provide a de?ed state and prevent a ?ating input, thereby preventing unnecessary current consumption at the input stage. pin name function 1 pin name function 2 power domain internal pull resistor description ctrl reset state pk[2:0] xaddr[16:14] v ddx pupke up port k i/o pins
appendix c package information freescale semiconductor mc9s12q128 633 rev 1.09 appendix c package information c.1 general this section provides the physical dimensions of the packages 48lqfp, 52lqfp, 80qfp.
appendix c package information 634 mc9s12q128 freescale semiconductor rev 1.09 c.1.1 80-pin qfp package figure c-1. 80-pin qfp mechanical dimensions (case no. 841b) notes: 1. dimensioning and tolerancing per ansi y14.5m, 1982. 2. controlling dimension: millimeter. 3. datum plane -h- is located at bottom of lead and is coincident with the lead where the lead exits the plastic body at the bottom of the parting line. 4. datums -a-, -b- and -d- to be determined at datum plane -h-. 5. dimensions s and v to be determined at seating plane -c-. 6. dimensions a and b do not include mold protrusion. allowable protrusion is 0.25 per side. dimensions a and b do include mold mismatch and are determined at datum plane -h-. 7. dimension d does not include dambar protrusion. allowable dambar protrusion shall be 0.08 total in excess of the d dimension at maximum material condition. dambar cannot be located on the lower radius or the foot. section b-b 61 60 detail a l 41 40 80 -a- l -d- a s a-b m 0.20 d s h 0.05 a-b s 120 21 -b- b v j f n d view rotated 90 detail a b b p -a-,-b-,-d- e h g m m detail c seating plane -c- c datum plane 0.10 -h- datum plane -h- u t r q k w x detail c dim min max millimeters a 13.90 14.10 b 13.90 14.10 c 2.15 2.45 d 0.22 0.38 e 2.00 2.40 f 0.22 0.33 g 0.65 bsc h --- 0.25 j 0.13 0.23 k 0.65 0.95 l 12.35 ref m 510 n 0.13 0.17 p 0.325 bsc q 07 r 0.13 0.30 s 16.95 17.45 t 0.13 --- u 0 --- v 16.95 17.45 w 0.35 0.45 x 1.6 ref s a-b m 0.20 d s c s a-b m 0.20 d s h 0.05 d s a-b m 0.20 d s c s a-b m 0.20 d s c
appendix c package information freescale semiconductor mc9s12q128 635 rev 1.09 c.1.2 52-pin lqfp package figure c-2. 52-pin lqfp mechanical dimensions (case no. 848d-03) f notes: 1. dimensioning and tolerancing per ansi y14.5m, 1982. controlling dimension: millimeter datum plane -h- is located at bottom of lead and is coincident with the lead where the lead exits the plastic body at the bottom of the parting line. 2. datums -l-, -m- and -n- to be determined at datum plane -h-. dimensions s and v to be determined at seating plane -t-. dimensions a and b do not include mold protrusion. allowable protrusion is 0.25 (0.010) per side. dimensions a and b do include mold mismatch and are determined at datum plane -h- dimension d does not include dambar protrusion. dambar protrusion shall not cause the lead width to exceed 0.46 (0.018). minimum space between protrusion and adjacent lead or protrusion 0.07 (0.003). view aa ab ab view y section ab-ab rotated 90 clockwise dim a min max min max inches 10.00 bsc 0.394 bsc millimeters a1 5.00 bsc 0.197 bsc b 10.00 bsc 0.394 bsc b1 5.00 bsc 0.197 bsc c --- 1.70 --- 0.067 c1 0.05 0.20 0.002 0.008 c2 1.30 1.50 0.051 0.059 d 0.20 0.40 0.008 0.016 e 0.45 0.030 f 0.22 0.35 0.009 0.014 g 0.65 bsc 0.75 0.018 0.026 bsc j 0.07 0.20 0.003 0.008 k 0.50 ref 0.020 ref r1 0.08 0.20 0.003 0.008 s 12.00 bsc 0.472 bsc s1 6.00 bsc 0.236 bsc u 0.09 0.16 0.004 0.006 v 12.00 bsc 0.472 bsc v1 6.00 bsc 0.236 bsc w 0.20 ref 0.008 ref z 1.00 ref 0.039 ref c l -x- x=l, m, n 1 13 14 26 27 39 40 52 4x 13 tips 4x n 0.20 (0.008) h l-m n 0.20 (0.008) t l-m seating plane c 0.10 (0.004) t 4x 3 4x 2 s 0.05 (0.002) 0.25 (0.010) gage plane c2 c1 w k e z s l-m m 0.13 (0.005) n s t plating base metal d j u b v b1 a s v1 a1 s1 -l- -n- -m- -h- -t- 1 g 1 3 2 07 12 07 0 0 --- --- ref 12 ref 3x view y view aa 2x r r1 12 ref 12 ref
appendix c package information 636 mc9s12q128 freescale semiconductor rev 1.09 c.1.3 48-pin lqfp package figure c-3. 48-pin lqfp mechanical dimensions (case no. 932-03 issue f) a a1 z 0.200 ab t-u 4x z 0.200 ac t-u 4x b b1 1 12 13 24 25 36 37 48 s1 s v v1 p ae ae t, u, z detail y detail y base metal n j f d t-u m 0.080 z ac section ae-ae ad g 0.080 ac m top & bottom l w k aa e c h 0.250 r 9 detail ad notes: 1. dimensioning and tolerancing per asme y14.5m, 1994. 2. controlling dimension: millimeter. 3. datum plane ab is located at bottom of lead and is coincident with the lead where the lead exits the plastic body at the bottom of the parting line. 4. datums t, u, and z to be determined at datum plane ab. 5. dimensions s and v to be determined at seating plane ac. 6. dimensions a and b do not include mold protrusion. allowable protrusion is 0.250 per side. dimensions a and b do include mold mismatch and are determined at datum plane ab. 7. dimension d does not include dambar protrusion. dambar protrusion shall not cause the d dimension to exceed 0.350. t u z ab ac gauge plane dim a min max 7.000 bsc millimeters a1 3.500 bsc b 7.000 bsc b1 3.500 bsc c 1.400 1.600 d 0.170 0.270 e 1.350 1.450 f 0.170 0.230 g 0.500 bsc h 0.050 0.150 j 0.090 0.200 k 0.500 0.700 m 12 ref n 0.090 0.160 p 0.250 bsc l 07 r 0.150 0.250 s 9.000 bsc s1 4.500 bsc v 9.000 bsc v1 4.500 bsc w 0.200 ref aa 1.000 ref
appendix d derivative differences freescale semiconductor mc9s12q128 637 rev 1.09 appendix d derivative differences the device user guide provides information about the mc9s12q-family. the q-family offers an extensive range of package, temperature and speed options. table d-1. shows a feature overview of the q family members. table d-1. list of mc9s12q and mc3s12q family members flash rom ram package device can sci spi a/d pwm timer i/o (1) 1. includes 2 input only pins (irq and xirq) 128k 4k 48lqfp mc9s12q128 1 1 1 8ch 4ch 6ch 31 52lqfp mc9s12q128 1 1 1 8ch 4ch 6ch 35 80qfp mc9s12q128 1 1 1 8ch 4ch 6ch 60 96k 3k 48lqfp mc9s12q96 1 1 1 8ch 4ch 6ch 31 52lqfp mc9s12q96 1 1 1 8ch 4ch 6ch 35 80qfp mc9s12q96 1 1 1 8ch 4ch 6ch 60 64k 2k 48lqfp mc9s12q64 1 1 1 8ch 6ch 31 52lqfp mc9s12q64 1 1 1 8ch 6ch 35 32k 1k 48lqfp mc9s12q32 1 1 1 8ch 6ch 31 52lqfp mc9s12q32 1 1 1 8ch 6ch 35 128k 4k 48lqfp mc3s12q128 1 1 1 8ch 4ch 6ch 31 52lqfp mc3s12q128 1 1 1 8ch 4ch 6ch 35 80qfp mc3s12q128 1 1 1 8ch 4ch 6ch 60 96k 3k 48lqfp mc3s12q96 1 1 1 8ch 4ch 6ch 31 52lqfp mc3s12q96 1 1 1 8ch 4ch 6ch 35 80qfp mc3s12q96 1 1 1 8ch 4ch 6ch 60 64k 2k 48lqfp mc3s12q64 1 1 1 8ch 6ch 31 52lqfp mc3s12q64 1 1 1 8ch 6ch 35 32k 1k 48lqfp mc3s12q32 1 1 1 8ch 6ch 31 52lqfp mc3s12q32 1 1 1 8ch 6ch 35
appendix e ordering information 638 mc9s12q128 freescale semiconductor rev 1.09 appendix e ordering information figure e-1. order part number coding table e-1. mc9s12q128 part number coding part number mask (1) set temp. package speed die type flash ram i/o (2) , (3) mc9s12q128cfa16 xl09s/xm66g -40?c, 85?c 48lqfp 16mhz c128 die 128k 4k 31 mc9s12q128cpb16 xl09s/xm66g -40?c, 85?c 52lqfp 16mhz c128 die 128k 4k 35 mc9s12q128cfu16 xl09s/xm66g -40?c, 85?c 80qfp 16mhz c128 die 128k 4k 60 mc9s12q128vfa16 xl09s/xm66g -40?c,105?c 48lqfp 16mhz c128 die 128k 4k 31 mc9s12q128vpb16 xl09s/xm66g -40?c,105?c 52lqfp 16mhz c128 die 128k 4k 35 mc9s12q128vfu16 xl09s/xm66g -40?c, 105?c 80qfp 16mhz c128 die 128k 4k 60 mc9s12q128mfa16 xl09s/xm66g -40?c,125?c 48lqfp 16mhz c128 die 128k 4k 31 mc9s12q128mpb16 xl09s/xm66g -40?c,125?c 52lqfp 16mhz c128 die 128k 4k 35 mc9s12q128mfu16 xl09s/xm66g -40?c, 125?c 80qfp 16mhz c128 die 128k 4k 60 mc9s12q128cfa8 xl09s/xm66g -40?c, 85?c 48lqfp 8mhz c128 die 128k 4k 31 mc9s12q128cpb8 xl09s/xm66g -40?c, 85?c 52lqfp 8mhz c128 die 128k 4k 35 mc9s12q128cfu8 xl09s/xm66g -40?c, 85?c 80qfp 8mhz c128 die 128k 4k 60 mc9s12q128vfa8 xl09s/xm66g -40?c,105?c 48lqfp 8mhz c128 die 128k 4k 31 mc9s12q128vpb8 xl09s/xm66g -40?c,105?c 52lqfp 8mhz c128 die 128k 4k 35 mc9s12q128vfu8 xl09s/xm66g -40?c, 105?c 80qfp 8mhz c128 die 128k 4k 60 mc9s12q128mfa8 xl09s/xm66g -40?c,125?c 48lqfp 8mhz c128 die 128k 4k 31 mc9s12q128mpb8 xl09s/xm66g -40?c,125?c 52lqfp 8mhz c128 die 128k 4k 35 mc9s12q128mfu8 xl09s/xm66g -40?c, 125?c 80qfp 8mhz c128 die 128k 4k 60 mc9s12q96cfa16 xl09s/xm66g -40?c, 85?c 48lqfp 16mhz c128 die 96k 3k 31 mc9s12q96cpb16 xl09s/xm66g -40?c, 85?c 52lqfp 16mhz c128 die 96k 3k 35 mc9s12q96cfu16 xl09s/xm66g -40?c, 85?c 80qfp 16mhz c128 die 96k 3k 60 mc9s12q96vfa16 xl09s/xm66g -40?c,105?c 48lqfp 16mhz c128 die 96k 3k 31 mc9s12q96vpb16 xl09s/xm66g -40?c,105?c 52lqfp 16mhz c128 die 96k 3k 35 mc9s12q96vfu16 xl09s/xm66g -40?c, 105?c 80qfp 16mhz c128 die 96k 3k 60 mc9s12q96mfa16 xl09s/xm66g -40?c,125?c 48lqfp 16mhz c128 die 96k 3k 31 mc9s12 q32 c fu 16 package option temperature option device title controller family temperature options c = -40?c to 85?c v = -40?c to 105?c m = -40?c to 125?c package options fu = 80qfp pb = 52lqfp fa = 48lqfp speed option speed options 8 = 8mhz bus 16 = 16mhz bus
appendix e ordering information freescale semiconductor mc9s12q128 639 rev 1.09 mc9s12q96mpb16 xl09s/xm66g -40?c,125?c 52lqfp 16mhz c128 die 96k 3k 35 mc9s12q96mfu16 xl09s/xm66g -40?c, 125?c 80qfp 16mhz c128 die 96k 3k 60 mc9s12q96cfa8 xl09s/xm66g -40?c, 85?c 48lqfp 8mhz c128 die 96k 3k 31 mc9s12q96cpb8 xl09s/xm66g -40?c, 85?c 52lqfp 8mhz c128 die 96k 3k 35 mc9s12q96cfu8 xl09s/xm66g -40?c, 85?c 80qfp 8mhz c128 die 96k 3k 60 mc9s12q96vfa8 xl09s/xm66g -40?c,105?c 48lqfp 8mhz c128 die 96k 3k 31 mc9s12q96vpb8 xl09s/xm66g -40?c,105?c 52lqfp 8mhz c128 die 96k 3k 35 mc9s12q96vfu8 xl09s/xm66g -40?c, 105?c 80qfp 8mhz c128 die 96k 3k 60 mc9s12q96mfa8 xl09s/xm66g -40?c,125?c 48lqfp 8mhz c128 die 96k 3k 31 mc9s12q96mpb8 xl09s/xm66g -40?c,125?c 52lqfp 8mhz c128 die 96k 3k 35 mc9s12q96mfu8 xl09s/xm66g -40?c, 125?c 80qfp 8mhz c128 die 96k 3k 60 mc9s12q64cfa16 xl09s/xm66g -40?c, 85?c 48lqfp 16mhz c128 die 64k 2k 31 mc9s12q64cpb16 xl09s/xm66g -40?c, 85?c 52lqfp 16mhz c128 die 64k 2k 35 mc9s12q64vfa16 xl09s/xm66g -40?c,105?c 48lqfp 16mhz c128 die 64k 2k 31 mc9s12q64vpb16 xl09s/xm66g -40?c,105?c 52lqfp 16mhz c128 die 64k 2k 35 mc9s12q64mfa16 xl09s/xm66g -40?c,125?c 48lqfp 16mhz c128 die 64k 2k 31 mc9s12q64mpb16 xl09s/xm66g -40?c,125?c 52lqfp 16mhz c128 die 64k 2k 35 mc9s12q64cfa8 xl09s/xm66g -40?c, 85?c 48lqfp 8mhz c128 die 64k 2k 31 mc9s12q64cpb8 xl09s/xm66g -40?c, 85?c 52lqfp 8mhz c128 die 64k 2k 35 mc9s12q64vfa8 xl09s/xm66g -40?c,105?c 48lqfp 8mhz c128 die 64k 2k 31 mc9s12q64vpb8 xl09s/xm66g -40?c,105?c 52lqfp 8mhz c128 die 64k 2k 35 mc9s12q64mfa8 xl09s/xm66g -40?c,125?c 48lqfp 8mhz c128 die 64k 2k 31 mc9s12q64mpb8 xl09s/xm66g -40?c,125?c 52lqfp 8mhz c128 die 64k 2k 35 mc9s12q32cfa16 xl45j / xm34c -40?c, 85?c 48lqfp 16mhz c32 die 32k 1k 31 mc9s12q32cpb16 xl45j / xm34c -40?c, 85?c 52lqfp 16mhz c32 die 32k 1k 35 mc9s12q32vfa16 xl45j / xm34c -40?c,105?c 48lqfp 16mhz c32 die 32k 1k 31 mc9s12q32vpb16 xl45j / xm34c -40?c,105?c 52lqfp 16mhz c32 die 32k 1k 35 mc9s12q32mfa16 xl45j / xm34c -40?c,125?c 48lqfp 16mhz c32 die 32k 1k 31 mc9s12q32mpb16 xl45j / xm34c -40?c,125?c 52lqfp 16mhz c32 die 32k 1k 35 mc9s12q32cfa8 xl45j / xm34c -40?c, 85?c 48lqfp 8mhz c32 die 32k 1k 31 mc9s12q32cpb8 xl45j / xm34c -40?c, 85?c 52lqfp 8mhz c32 die 32k 1k 35 mc9s12q32vfa8 xl45j / xm34c -40?c,105?c 48lqfp 8mhz c32 die 32k 1k 31 mc9s12q32vpb8 xl45j / xm34c -40?c,105?c 52lqfp 8mhz c32 die 32k 1k 35 mc9s12q32mfa8 xl45j / xm34c -40?c,125?c 48lqfp 8mhz c32 die 32k 1k 31 mc9s12q32mpb8 xl45j / xm34c -40?c,125?c 52lqfp 8mhz c32 die 32k 1k 35 mc3s12q128cfa16 xl09s/xm66g -40?c, 85?c 48lqfp 16mhz c128 die 128k 4k 31 mc3s12q128cpb16 xl09s/xm66g -40?c, 85?c 52lqfp 16mhz c128 die 128k 4k 35 mc3s12q128cfu16 xl09s/xm66g -40?c, 85?c 80qfp 16mhz c128 die 128k 4k 60 mc3s12q128vfa16 xl09s/xm66g -40?c,105?c 48lqfp 16mhz c128 die 128k 4k 31 mc3s12q128vpb16 xl09s/xm66g -40?c,105?c 52lqfp 16mhz c128 die 128k 4k 35 mc3s12q128vfu16 xl09s/xm66g -40?c, 105?c 80qfp 16mhz c128 die 128k 4k 60 mc3s12q128mfa16 xl09s/xm66g -40?c,125?c 48lqfp 16mhz c128 die 128k 4k 31 mc3s12q128mpb16 xl09s/xm66g -40?c,125?c 52lqfp 16mhz c128 die 128k 4k 35 part number mask (1) set temp. package speed die type flash ram i/o (2) , (3)
appendix e ordering information 640 mc9s12q128 freescale semiconductor rev 1.09 mc3s12q128mfu16 xl09s/xm66g -40?c, 125?c 80qfp 16mhz c128 die 128k 4k 60 mc3s12q128cfa8 xl09s/xm66g -40?c, 85?c 48lqfp 8mhz c128 die 128k 4k 31 mc3s12q128cpb8 xl09s/xm66g -40?c, 85?c 52lqfp 8mhz c128 die 128k 4k 35 mc3s12q128cfu8 xl09s/xm66g -40?c, 85?c 80qfp 8mhz c128 die 128k 4k 60 mc3s12q128vfa8 xl09s/xm66g -40?c,105?c 48lqfp 8mhz c128 die 128k 4k 31 mc3s12q128vpb8 xl09s/xm66g -40?c,105?c 52lqfp 8mhz c128 die 128k 4k 35 mc3s12q128vfu8 xl09s/xm66g -40?c, 105?c 80qfp 8mhz c128 die 128k 4k 60 mc3s12q128mfa8 xl09s/xm66g -40?c,125?c 48lqfp 8mhz c128 die 128k 4k 31 mc3s12q128mpb8 xl09s/xm66g -40?c,125?c 52lqfp 8mhz c128 die 128k 4k 35 mc3s12q128mfu8 xl09s/xm66g -40?c, 125?c 80qfp 8mhz c128 die 128k 4k 60 mc3s12q96cfa16 xl09s/xm66g -40?c, 85?c 48lqfp 16mhz c128 die 96k 3k 31 mc3s12q96cpb16 xl09s/xm66g -40?c, 85?c 52lqfp 16mhz c128 die 96k 3k 35 mc3s12q96cfu16 xl09s/xm66g -40?c, 85?c 80qfp 16mhz c128 die 96k 3k 60 mc3s12q96vfa16 xl09s/xm66g -40?c,105?c 48lqfp 16mhz c128 die 96k 3k 31 mc3s12q96vpb16 xl09s/xm66g -40?c,105?c 52lqfp 16mhz c128 die 96k 3k 35 mc3s12q96vfu16 xl09s/xm66g -40?c, 105?c 80qfp 16mhz c128 die 96k 3k 60 mc3s12q96mfa16 xl09s/xm66g -40?c,125?c 48lqfp 16mhz c128 die 96k 3k 31 mc3s12q96mpb16 xl09s/xm66g -40?c,125?c 52lqfp 16mhz c128 die 96k 3k 35 mc3s12q96mfu16 xl09s/xm66g -40?c, 125?c 80qfp 16mhz c128 die 96k 3k 60 mc3s12q96cfa8 xl09s/xm66g -40?c, 85?c 48lqfp 8mhz c128 die 96k 3k 31 mc3s12q96cpb8 xl09s/xm66g -40?c, 85?c 52lqfp 8mhz c128 die 96k 3k 35 mc3s12q96cfu8 xl09s/xm66g -40?c, 85?c 80qfp 8mhz c128 die 96k 3k 60 mc3s12q96vfa8 xl09s/xm66g -40?c,105?c 48lqfp 8mhz c128 die 96k 3k 31 mc3s12q96vpb8 xl09s/xm66g -40?c,105?c 52lqfp 8mhz c128 die 96k 3k 35 mc3s12q96vfu8 xl09s/xm66g -40?c, 105?c 80qfp 8mhz c128 die 96k 3k 60 mc3s12q96mfa8 xl09s/xm66g -40?c,125?c 48lqfp 8mhz c128 die 96k 3k 31 mc3s12q96mpb8 xl09s/xm66g -40?c,125?c 52lqfp 8mhz c128 die 96k 3k 35 mc3s12q96mfu8 xl09s/xm66g -40?c, 125?c 80qfp 8mhz c128 die 96k 3k 60 mc3s12q64cfa16 xl09s/xm66g -40?c, 85?c 48lqfp 16mhz c128 die 64k 2k 31 mc3s12q64cpb16 xl09s/xm66g -40?c, 85?c 52lqfp 16mhz c128 die 64k 2k 35 mc3s12q64vfa16 xl09s/xm66g -40?c,105?c 48lqfp 16mhz c128 die 64k 2k 31 mc3s12q64vpb16 xl09s/xm66g -40?c,105?c 52lqfp 16mhz c128 die 64k 2k 35 mc3s12q64mfa16 xl09s/xm66g -40?c,125?c 48lqfp 16mhz c128 die 64k 2k 31 mc3s12q64mpb16 xl09s/xm66g -40?c,125?c 52lqfp 16mhz c128 die 64k 2k 35 mc3s12q64cfa8 xl09s/xm66g -40?c, 85?c 48lqfp 8mhz c128 die 64k 2k 31 mc3s12q64cpb8 xl09s/xm66g -40?c, 85?c 52lqfp 8mhz c128 die 64k 2k 35 mc3s12q64vfa8 xl09s/xm66g -40?c,105?c 48lqfp 8mhz c128 die 64k 2k 31 mc3s12q64vpb8 xl09s/xm66g -40?c,105?c 52lqfp 8mhz c128 die 64k 2k 35 mc3s12q64mfa8 xl09s/xm66g -40?c,125?c 48lqfp 8mhz c128 die 64k 2k 31 mc3s12q64mpb8 xl09s/xm66g -40?c,125?c 52lqfp 8mhz c128 die 64k 2k 35 mc3s12q32cfa16 xl45j / xm34c -40?c, 85?c 48lqfp 16mhz c32 die 32k 1k 31 mc3s12q32cpb16 xl45j / xm34c -40?c, 85?c 52lqfp 16mhz c32 die 32k 1k 35 MC3S12Q32VFA16 xl45j / xm34c -40?c,105?c 48lqfp 16mhz c32 die 32k 1k 31 part number mask (1) set temp. package speed die type flash ram i/o (2) , (3)
appendix e ordering information freescale semiconductor mc9s12q128 641 rev 1.09 mc3s12q32vpb16 xl45j / xm34c -40?c,105?c 52lqfp 16mhz c32 die 32k 1k 35 mc3s12q32mfa16 xl45j / xm34c -40?c,125?c 48lqfp 16mhz c32 die 32k 1k 31 mc3s12q32mpb16 xl45j / xm34c -40?c,125?c 52lqfp 16mhz c32 die 32k 1k 35 mc3s12q32cfa8 xl45j / xm34c -40?c, 85?c 48lqfp 8mhz c32 die 32k 1k 31 mc3s12q32cpb8 xl45j / xm34c -40?c, 85?c 52lqfp 8mhz c32 die 32k 1k 35 mc3s12q32vfa8 xl45j / xm34c -40?c,105?c 48lqfp 8mhz c32 die 32k 1k 31 mc3s12q32vpb8 xl45j / xm34c -40?c,105?c 52lqfp 8mhz c32 die 32k 1k 35 mc3s12q32mfa8 xl45j / xm34c -40?c,125?c 48lqfp 8mhz c32 die 32k 1k 31 mc3s12q32mpb8 xl45j / xm34c -40?c,125?c 52lqfp 8mhz c32 die 32k 1k 35 1. xl09s denotes all minor revisions of l09s maskset xl45j denotes all minor revisions of l45j maskset maskset dependent errata can be accessed at http://e-www.motorola.com/wbapp/sps/site/prod_summary.jsp 2. all q-family derivatives feature 1 can, 1 sci, 1 spi, an 8-channel a/d, and a 6 channel timer. the q128 and q96 also feature a 4 channel pwm. the q64 and q32 do not feature a pwm. 3. i/o is the sum of ports able to act as digital input or output. part number mask (1) set temp. package speed die type flash ram i/o (2) , (3)
appendix e ordering information 642 mc9s12q128 freescale semiconductor rev 1.09

how to reach us: home page: www.freescale.com usa/europe or locations not listed: freescale semiconductor technical information center, ch370 1300 n. alma school road chandler, arizona 85224 1-800-521-6274 or 480-768-2130 europe, middle east, and africa: +44 1296 380 456 (english) +46 8 52200080 (english) +49 89 92103 559 (german) +33 1 69 35 48 48 (french) japan: freescale semiconductor japan ltd. technical information center 3-20-1, minami-azabu, minato-ku tokyo 106-0047, japan 0120-191014 or +81-3-3440-3569 asia/paci?: freescale semiconductor hong kong ltd. technical information center 2 dai king street tai po industrial estate tai po, n.t., hong kong 852-26668334 for literature requests only: freescale semiconductor literature distribution center p.o. box 5405 denver, colorado 80217 1-800-441-2447 or 303-675-2140 fax: 303-675-2150 freescale and the freescale logo are trademarks of freescale semiconductor, inc. all other product or service names are the property of their respective owners. . ?freescale semiconductor, inc. 2006. all rights reserved. mc9s12q128 rev 1.09 12/2007 information in this document is provided solely to enable system and software implementers to use freescale semiconductor products. there are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. freescale semiconductor reserves the right to make changes without further notice to any products herein. freescale semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does freescale semiconductor assume any liability arising out of the application or use of any product or circuit, and speci?ally disclaims any and all liability, including without limitation consequential or incidental damages. typical parameters that may be provided in freescale semiconductor data sheets and/or speci?ations can and do vary in different applications and actual performance may vary over time. all operating parameters, including ?ypicals? must be validated for each customer application by customers technical experts. freescale semiconductor does not convey any license under its patent rights nor the rights of others. freescale semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the freescale semiconductor product could create a situation where personal injury or death may occur. should buyer purchase or use freescale semiconductor products for any such unintended or unauthorized application, buyer shall indemnify and hold freescale semiconductor and its of?ers, employees, subsidiaries, af?iates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that freescale semiconductor was negligent regarding the design or manufacture of the part.


▲Up To Search▲   

 
Price & Availability of MC3S12Q32VFA16

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X